I have 3 partials and 1 data file which are part of the problem.
buttons.json
{
"showAll": {
"element": "a",
"href": "-",
"text": "Show All"
},
"greenFlatSubmit": {
"element": "button",
"type": "submit",
"text": "Submit",
"color": "green",
"style": "flat"
},
"greenFlatCancel": {
"element": "button",
"type": "cancel",
"text": "Cancel",
"color": "green",
"style": "flat"
}
}
button.hbs
<{{ element }}{{#is element "a"}} href="{{ href }}"{{/is }}{{#if type }} type="{{ type }}"{{/if }} class="bd-button{{#if color }} bd-{{color}}{{/if }}{{#if style }} bd-{{style}}{{/if }}">{{ text }}</{{ element }}>
show-all-button.hbs
<div class="bd-button-container bd-show-all">
{{>button buttons.showAll }}
</div>
leave-comment-form.hbs
<form class="bd-leave-comment-form" action="#">
<div class="bd-container bd-user-photo">
{{>user-photo }}
</div>
<div class="bd-container bd-user-message">
<div class="bd-field">
<label class="bd-textarea-label" for="">Leave a comment</label>
<textarea name="#" id="" placeholder="Leave a comment"></textarea>
</div>
{{>button buttons.greenFlatSubmit }}
{{>button buttons.greenFlatCancel }}
</div>
</form>
Basically, what I have going on here is that I have 2 partials (show-all-button and leave-comment-form) which are including the button partial and passing in data from the buttons JSON file. When I try to grunt, I'm getting an error saying:
Warning: Cannot read property 'element' of undefined Use --force to continue.
So, I removed both button partial calls from both files and I put some logging info at the top of leave-comment-form.hbs:
{{ log "leave-comment-form.hbs" }}
{{ log buttons }}
And when I grunt, I get this:
leave-comment-form.hbs
{ showAll: { element: 'a', href: '-', text: 'Show All' },
greenFlatSubmit:
{ element: 'button',
type: 'submit',
text: 'Submit',
color: 'green',
style: 'flat' },
greenFlatCancel:
{ element: 'button',
type: 'cancel',
text: 'Cancel',
color: 'green',
style: 'flat' } }
So that's good. We know that the leave-comment-form.hbs partial is getting the buttons.json. But when I remove the logging from the top of leave-comment-form.hbs and put it into show-all-button.hbs, I get this error:
show-all-button.hbs
undefined
show-all-button.hbs
{ showAll: { element: 'a', href: '-', text: 'Show All' },
greenFlatSubmit:
{ element: 'button',
type: 'submit',
text: 'Submit',
color: 'green',
style: 'flat' },
greenFlatCancel:
{ element: 'button',
type: 'cancel',
text: 'Cancel',
color: 'green',
style: 'flat' } }
show-all-button is getting called in two places from two different templates. Obviously buttons.json is available to the partial at one of the calls in the one file but not the other one. How could the data only be available to one partial call if it's global data?
I have 3 partials and 1 data file which are part of the problem.
buttons.json
button.hbs
show-all-button.hbs
leave-comment-form.hbs
Basically, what I have going on here is that I have 2 partials (show-all-button and leave-comment-form) which are including the button partial and passing in data from the buttons JSON file. When I try to grunt, I'm getting an error saying:
So, I removed both button partial calls from both files and I put some logging info at the top of
leave-comment-form.hbs:And when I grunt, I get this:
So that's good. We know that the leave-comment-form.hbs partial is getting the buttons.json. But when I remove the logging from the top of
leave-comment-form.hbsand put it intoshow-all-button.hbs, I get this error:show-all-buttonis getting called in two places from two different templates. Obviously buttons.json is available to the partial at one of the calls in the one file but not the other one. How could the data only be available to one partial call if it's global data?