-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: simplify the template component's rendering function
- Loading branch information
Showing
6 changed files
with
155 additions
and
3 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
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const san = require('san') | ||
const List = san.defineTemplateComponent({ | ||
initData () { | ||
return { | ||
text: 'child' | ||
} | ||
}, | ||
template: '<div>{{ text }}</div>' | ||
}) | ||
|
||
const CompB = san.defineTemplateComponent({ | ||
initData () { | ||
return { | ||
text: 'comp b' | ||
} | ||
}, | ||
template: '<div>{{ text }}</div>' | ||
}) | ||
const CompA = san.defineComponent({ | ||
components: { | ||
'x-l': CompB | ||
}, | ||
initData () { | ||
return { | ||
text: 'component a' | ||
} | ||
}, | ||
template: '<div><div>{{ text }}</div><x-l/></div>' | ||
}) | ||
|
||
const MyComponent = san.defineComponent({ | ||
components: { | ||
'x-l': List, | ||
'x-g': san.createComponentLoader({ | ||
load: () => { | ||
return List | ||
}, | ||
placeholder: CompA | ||
}) | ||
}, | ||
initData () { | ||
return { | ||
c: 'x-l' | ||
} | ||
}, | ||
trimWhitespace: 'all', | ||
template: `<div> | ||
<div s-is="c"></div> | ||
<x-l/> | ||
<x-g/> | ||
</div>` | ||
}) | ||
|
||
exports = module.exports = MyComponent |
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,2 @@ | ||
{ | ||
} |
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 @@ | ||
<div><!--s-data:{"c": "x-l"}--><div>child</div><div>child</div><div><div>component a</div><div>comp b</div></div></div> |
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,12 @@ | ||
import type { SsrSpecConfig } from '../../e2e.spec' | ||
|
||
export default { | ||
enabled: { | ||
jssrc: false, | ||
comsrc: true, | ||
comrdr: false | ||
}, | ||
compileOptions: { | ||
useProvidedComponentClass: true | ||
} | ||
} as SsrSpecConfig |