I'm pretty lost after trying numerous different things. I am building an Ember site and inside of one of my Handlebars templates, I want to display a link only if a condition is true. Here is my template.
<script type="text/x-handlebars" data-template-name="project">
<div class="project-container">
{{is_external model.url model.title}}
</div>
</script>
Now, my registerHelper in my js file:
Handlebars.registerHelper('is_external', function(url, title, options) {
if (url.indexOf("codepen") < 0) {
return "<p class='view-external-link'>"+
"<a href='{{url}}'' aria-label='View {{title}}'' target='_blank'>Visit Site</a>"+
"</p>";
}
});
The error I keep receiving however, is: Uncaught TypeError: Cannot read property 'isHelperFactory' of undefined coming from my ember.js file.
Ideally, I would prefer to just return true or false from the helper to keep the Html out of my helper function but first I just need some help getting it working.
I am including ember, ember_compiler, and handlebars on my page as well.
Aucun commentaire:
Enregistrer un commentaire