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

Example Handlebars template #181

Closed
MatthewScheuerman opened this issue Oct 23, 2018 · 8 comments
Closed

Example Handlebars template #181

MatthewScheuerman opened this issue Oct 23, 2018 · 8 comments

Comments

@MatthewScheuerman
Copy link

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?

@chazzmoney
Copy link
Collaborator

chazzmoney commented Oct 23, 2018

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!

@MatthewScheuerman
Copy link
Author

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.

@dbanksdesign
Copy link
Member

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...

@chazzmoney
Copy link
Collaborator

@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?

@MatthewScheuerman
Copy link
Author

@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!

@dbanksdesign
Copy link
Member

@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

@MatthewScheuerman
Copy link
Author

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

@chazzmoney
Copy link
Collaborator

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

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

3 participants