Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support usage indirection #90

Closed
jamesarosen opened this issue Dec 6, 2016 · 3 comments
Closed

Support usage indirection #90

jamesarosen opened this issue Dec 6, 2016 · 3 comments

Comments

@jamesarosen
Copy link

I have 30 different icons whose docs each look like

{{#freestyle-usage 'icon-pencil' title='Pencil'}}
  <svg class='icon pencil'>
    <use xlink:href="assets/my-app/icons.svg#pencil"></use>
  </svg>
{{/freestyle-usage}}

I wanted to DRY that up with something like

{{#each icons as |icon|}}
  {{#freestyle-usage (concat 'icon-' icon.name) title=icon.title}}
    <svg class='icon {{icon.name}}'>
      <use xlink:href="assets/my-app/icons.svg#{{icon.name}}"></use>
    </svg>
  {{/freestyle-usage}}
{{/each}}

While the rendered block shows up fine, the code snippet is blank.

I also tried

{{icon-usage usage name='pencil' title='Pencil'}}
{{icon-usage usage name='trash' title='Trashcan'}}

with

{{!-- app/templates/components/icon-usage.hbs --}}
{{#freestyle-usage (concat 'icon-' name) title=title}}
  <svg class='icon {{name}}'>
    <use xlink:href="assets/my-app/icons.svg#{{name}}"></use>
  </svg>
{{/freestyle-usage}}

with the same effect.

Is there something I can do to make ember-freestyle pick up the fact that I want each of those to get a usage snippet?

@chrislopresto
Copy link
Owner

@jamesarosen Interesting use case. We should try to come up with a nice pattern for this.

Right now, the addon's snippet finder uses naive text matching during the build step to look for the opening and closing freestyle-usage curlies. It has no concept of usage within an iterator.

What you'd need to do right now is create separate snippet files and reference them by name in your each block. This would probably be annoying to maintain, but it would work.

I have been mulling over something that could be semi-related, so let me know if you want to chat / pair.

@jamesarosen
Copy link
Author

Now that I think about it, perhaps I don't really want snippets for each of these. If they're really all variants on the same code, then I can do the code once at the top and then write all the instances as a table or a list or something.

@chrislopresto
Copy link
Owner

Ok. I'll close this in the meantime but continue to think this through.

Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants