-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from bertdeblock/support-class-based-modifiers
Support class-based modifiers
- Loading branch information
Showing
15 changed files
with
234 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/.scaffdog/documents/ | ||
/coverage/ | ||
/dist/ | ||
/documents/ | ||
/test/output/ | ||
/CHANGELOG.md | ||
/pnpm-lock.yaml |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export default { | ||
files: ["documents/*.md"], | ||
files: ["*.md"], | ||
tags: ["[[", "]]"], | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
--- | ||
name: "modifier" | ||
root: "." | ||
output: "**/*" | ||
--- | ||
|
||
# [[inputs.authoringFormat == "js" ? (inputs.classBased ? "!" : "") : "!"]][[inputs.name]].js | ||
|
||
```js | ||
[[name := camel(inputs.name)-]] | ||
|
||
import { modifier } from "ember-modifier"; | ||
|
||
export default modifier(function [[name]](element, positional, named) {}); | ||
|
||
``` | ||
|
||
# [[inputs.authoringFormat == "js" ? (inputs.classBased ? "" : "!") : "!"]][[inputs.name]].js | ||
|
||
```js | ||
[[name := pascal(inputs.name)-]] | ||
|
||
import Modifier from "ember-modifier"; | ||
|
||
export default class [[name]] extends Modifier { | ||
modify(element, positional, named) {} | ||
} | ||
|
||
``` | ||
|
||
# [[inputs.authoringFormat == "ts" ? (inputs.classBased ? "!" : "") : "!"]][[inputs.name]].ts | ||
|
||
```ts | ||
[[name := camel(inputs.name)-]] | ||
[[signature := (pascal(inputs.name) + "Signature")-]] | ||
|
||
import { modifier, type NamedArgs, type PositionalArgs } from "ember-modifier"; | ||
|
||
export interface [[signature]] { | ||
Args: { | ||
Named: {}; | ||
Positional: []; | ||
}; | ||
Element: null; | ||
} | ||
|
||
export default modifier<[[signature]]>(function [[name]](element, positional, named) {}); | ||
|
||
``` | ||
|
||
# [[inputs.authoringFormat == "ts" ? (inputs.classBased ? "" : "!") : "!"]][[inputs.name]].ts | ||
|
||
```ts | ||
[[name := pascal(inputs.name)-]] | ||
[[signature := (pascal(inputs.name) + "Signature")-]] | ||
|
||
import Modifier, { type NamedArgs, type PositionalArgs } from "ember-modifier"; | ||
|
||
export interface [[signature]] { | ||
Args: { | ||
Named: {}; | ||
Positional: []; | ||
}; | ||
Element: null; | ||
} | ||
|
||
export default class [[name]] extends Modifier<[[signature]]> { | ||
modify( | ||
element: [[signature]]["Element"], | ||
positional: PositionalArgs<[[signature]]>, | ||
named: NamedArgs<[[signature]]>, | ||
) {} | ||
} | ||
|
||
``` |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,75 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`generates a \`.js\` modifier 1`] = ` | ||
"import { modifier } from "ember-modifier"; | ||
exports[`generates a class-based \`.js\` modifier 1`] = ` | ||
"import Modifier from "ember-modifier"; | ||
export default modifier(function foo(element /*, positional, named*/) {}); | ||
export default class Foo extends Modifier { | ||
modify(element, positional, named) {} | ||
} | ||
" | ||
`; | ||
|
||
exports[`generates a \`.js\` modifier at a custom path 1`] = ` | ||
"import { modifier } from "ember-modifier"; | ||
exports[`generates a class-based \`.ts\` modifier 1`] = ` | ||
"import Modifier, { type NamedArgs, type PositionalArgs } from "ember-modifier"; | ||
export default modifier(function foo(element /*, positional, named*/) {}); | ||
export interface FooSignature { | ||
Args: { | ||
Named: {}; | ||
Positional: []; | ||
}; | ||
Element: null; | ||
} | ||
export default class Foo extends Modifier<FooSignature> { | ||
modify( | ||
element: FooSignature["Element"], | ||
positional: PositionalArgs<FooSignature>, | ||
named: NamedArgs<FooSignature>, | ||
) {} | ||
} | ||
" | ||
`; | ||
exports[`generates a \`.ts\` modifier 1`] = ` | ||
exports[`generates a function-based \`.js\` modifier 1`] = ` | ||
"import { modifier } from "ember-modifier"; | ||
export default modifier(function foo(element /*, positional, named*/) {}); | ||
export default modifier(function foo(element, positional, named) {}); | ||
" | ||
`; | ||
exports[`generates a \`.ts\` modifier at a custom path 1`] = ` | ||
exports[`generates a function-based \`.js\` modifier at a custom path 1`] = ` | ||
"import { modifier } from "ember-modifier"; | ||
export default modifier(function foo(element /*, positional, named*/) {}); | ||
export default modifier(function foo(element, positional, named) {}); | ||
" | ||
`; | ||
exports[`generates a function-based \`.ts\` modifier 1`] = ` | ||
"import { modifier, type NamedArgs, type PositionalArgs } from "ember-modifier"; | ||
export interface FooSignature { | ||
Args: { | ||
Named: {}; | ||
Positional: []; | ||
}; | ||
Element: null; | ||
} | ||
export default modifier<FooSignature>(function foo(element, positional, named) {}); | ||
" | ||
`; | ||
exports[`generates a function-based \`.ts\` modifier at a custom path 1`] = ` | ||
"import { modifier, type NamedArgs, type PositionalArgs } from "ember-modifier"; | ||
export interface FooSignature { | ||
Args: { | ||
Named: {}; | ||
Positional: []; | ||
}; | ||
Element: null; | ||
} | ||
export default modifier<FooSignature>(function foo(element, positional, named) {}); | ||
" | ||
`; |
Oops, something went wrong.