Skip to content

Commit

Permalink
refactor(tag): use main instead of yield for components
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Mar 21, 2017
1 parent e1445d8 commit b966077
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Tags/ComponentTag.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ class ComponentTag extends BaseTag {
slotLineNo = slotLineNo + child.childs.length + 1
} else {
slotLineNo++
result.yield.push(compiler.parseAndReturnLine(child))
result.main.push(compiler.parseAndReturnLine(child))
}
return result
}, {yield: []})
}, {main: []})

return transformedChilds
}
Expand Down
4 changes: 2 additions & 2 deletions test-helpers/views/components/alert.edge
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@if($slot.yield)
{{{ $slot.yield }}}
@if($slot.main)
{{{ $slot.main }}}
@else
<div class="header">
{{{ $slot.header }}}
Expand Down
12 changes: 6 additions & 6 deletions test/unit/tags/component.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ test.group('Tags | Component ', (group) => {
let out = new String()
this.isolate(function () {
out += \`\${this.runTimeRender('components.alert')}\\n\`
}.bind(this.newContext({$slot: { yield: \` <h2> Hello dude </h2>\` } })))
}.bind(this.newContext({$slot: { main: \` <h2> Hello dude </h2>\` } })))
return out
}).bind(this)()
`)
Expand All @@ -57,7 +57,7 @@ test.group('Tags | Component ', (group) => {
let out = new String()
this.isolate(function () {
out += \`\${this.runTimeRender('components.alert')}\\n\`
}.bind(this.newContext({username: 'virk'},{$slot: { yield: \` <h2> Hello dude </h2>\` } })))
}.bind(this.newContext({username: 'virk'},{$slot: { main: \` <h2> Hello dude </h2>\` } })))
return out
}).bind(this)()
`)
Expand All @@ -77,7 +77,7 @@ test.group('Tags | Component ', (group) => {
let out = new String()
this.isolate(function () {
out += \`\${this.runTimeRender('components.alert')}\\n\`
}.bind(this.newContext({username: this.context.resolve('username')},{$slot: { yield: \` <h2> Hello dude </h2>\` } })))
}.bind(this.newContext({username: this.context.resolve('username')},{$slot: { main: \` <h2> Hello dude </h2>\` } })))
return out
}).bind(this)()
`)
Expand All @@ -97,7 +97,7 @@ test.group('Tags | Component ', (group) => {
let out = new String()
this.isolate(function () {
out += \`\${this.runTimeRender('components.alert')}\\n\`
}.bind(this.newContext({username: this.context.resolve('username')},{$slot: { yield: \` <h2> Hello dude </h2>\` } })))
}.bind(this.newContext({username: this.context.resolve('username')},{$slot: { main: \` <h2> Hello dude </h2>\` } })))
return out
}).bind(this)()
`)
Expand All @@ -115,7 +115,7 @@ test.group('Tags | Component ', (group) => {
@endcomponent
`
const output = template.compileString(statement)
const slot = `{$slot: { yield: \`
const slot = `{$slot: { main: \`
This is the body\`, header: \` <h2> This is the header </h2>\` } }`

assert.equal(output, dedent`
Expand Down Expand Up @@ -143,7 +143,7 @@ test.group('Tags | Component ', (group) => {
@endcomponent
`
const output = template.compileString(statement)
const slot = `{$slot: { yield: \`\`, header: \` <h2> This is the header </h2>\`, body: \` This is the body\` } }`
const slot = `{$slot: { main: \`\`, header: \` <h2> This is the header </h2>\`, body: \` This is the body\` } }`

assert.equal(output, dedent`
return (function templateFn () {
Expand Down

0 comments on commit b966077

Please sign in to comment.