6

I want create a posts model, with tags, and be able to display all tags for each post. You know a best way to do it ??

I tried this

<template name='postsLists'>
  {{#each post}}
    {{> postDetails }}
  {{/each}}
</template>


<template name='postDetails'>
  title: {{title}}
  {{#each tag}}
    {{tag}}
  {{/each}}
</template>
1
  • Can you explain what exactly isn't working? Commented Jan 8, 2013 at 16:26

2 Answers 2

10

You need to use this keyword to get value from an array:

<template name='postDetails'>
  title: {{title}}
  {{#each tag}}
    {{this}}
  {{/each}}
</template>
Sign up to request clarification or add additional context in comments.

Comments

2

This code won't work:

{{#each tag}}
  {{tag}}
{{/each}}

because "tag" here refers to both the list and an element in that list. Try:

{{#each tags}}
  {{tag}}
{{/each}}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.