Style-dictionary: Example Handlebars template

Created on 23 Oct 2018  路  8Comments  路  Source: amzn/style-dictionary

Today I was trying to get a handlebars template up and running and couldn't.

Very low priority: but does anyone have an example handlebars template they would be ok with sharing?

All 8 comments

Hi @MatthewScheuerman,

I assume you mean a template for output using registerTemplate? If so, we will be deprecating that in the future. #152 will remove registerTemplates towards the more standard format methods. Examples on how to use templates for formats will be included in the documentation.

With that said, this is a specific example showing how you might add a Handlebars template using registerTemplate in the current system.

If you meant something else, please let us know and we can try to be more helpful.

Thanks!

Yep. We've been looking into the example of how you might add a Handlebars Template to the system...

But what I'm asking about is the actually the template itself. We have a template for markdown:

| Variable Name | Value | |
|---|---|---|<% _.each(allProperties, function(property) { %>
|$ourdesignsystem-<%= property.path.join("-") %>|<%= property.value %>  |<img src="https://via.placeholder.com/100x60/<%= checkForStyle(property) %>?text=<%= checkForStyle(property) %>">  |<% }); %>

But we're looking for just a small example like this in handlebars.

Full disclosure: I've never used handlebars before today and I've been having issues trying to get anything I write into a "MyTemplate.hbs" file to compile.

I keep getting:

Error: You must pass a string or Handlebars AST to Handlebars.compile. You passed...

and this is totally because I don't know what I'm doing regarding handlebars.

Hey @MatthewScheuerman I made a quick example package for ya: https://github.com/dbanksdesign/style-dictionary-example-handlebars

Let me know if that helps!

@chazzmoney we need to update our documentation a bit, the example code won't actually work...

@dbanksdesign Yikes! Can you make sure that what I have in #152 in terms of documentation will work? If not, can you correct it in remove-templates?

@dbanksdesign Thanks! Downloaded the code and I'm eager to dive into it more. Will the issue with what's in the documentation keep us from compiling? Regardless, I'll run it tomorrow and test. Thanks again!

@MatthewScheuerman The issue with the documentation shouldn't stop you, just follow the code that I posted, I tested it and it works. @chazzmoney I will make a PR to update the documentation in the remove-templates branch

@dbanksdesign Thanks for the help. that got us running with handlebars. Appreciated.

@MatthewScheuerman Thanks for pointing out the confusing documentation. This is fixed now w/ #182.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chemoish picture chemoish  路  3Comments

blackfalcon picture blackfalcon  路  4Comments

clepore picture clepore  路  5Comments

sarah-martinellibenedetti picture sarah-martinellibenedetti  路  4Comments

dbanksdesign picture dbanksdesign  路  5Comments