mirror of https://github.com/sveltejs/svelte
always use helpers if referenced, not just for CallExpressions, and warn on context clashes (#575)
parent
4f56b6553c
commit
75ea52754d
@ -0,0 +1,3 @@
|
||||
export default {
|
||||
html: '<p>1,4,9</p>'
|
||||
};
|
@ -0,0 +1,15 @@
|
||||
<p>{{numbers.map(square)}}</p>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
numbers: [ 1, 2, 3 ]
|
||||
};
|
||||
},
|
||||
|
||||
helpers: {
|
||||
square: num => num * num
|
||||
}
|
||||
};
|
||||
</script>
|
@ -0,0 +1,17 @@
|
||||
{{#each things as thing}}
|
||||
{{thing}}
|
||||
{{/each}}
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
return { things: [ 'a', 'b', 'c' ] };
|
||||
},
|
||||
|
||||
helpers: {
|
||||
thing: function ( x ) {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
@ -0,0 +1,8 @@
|
||||
[{
|
||||
"message": "Context clashes with a helper. Rename one or the other to eliminate any ambiguity",
|
||||
"loc": {
|
||||
"line": 1,
|
||||
"column": 18
|
||||
},
|
||||
"pos": 18
|
||||
}]
|
Loading…
Reference in new issue