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

[WIP] Precompile Handlebars templates #85

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

svizzari
Copy link
Collaborator

🐨 🚫 ⚠️

POC/WIP to precompile Handlebars templates on the server rather than in the client.

Note: this currently only services ZAT, ZAM would need to be independently updated if proceeding

/cc @danielbreves

Tasks

  • Investigate rendering out precompiled templates to a file, caching that file as an app asset
  • Investigate using handlebars.rb rather than execjs
  • Investigate correct function of custom Handlebars helpers
  • Investigate using Bower/NPM to pull in the Handlebars dependency
  • Update tests

References

  • Jira link:

Risks

  • [HIGH] Templates not rendering as expected

@svizzari
Copy link
Collaborator Author

/cc @ocke

<% unless templates.nil? %>
{
<% templates.each do |name, fn| %>
<%= name %>: <%= fn %>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to do the following to make it work:
That also what the normal compiler outputs btw (it wraps it into that Handlebars.template function).

-  <%= name %>: <%= fn %>,
+  <%= name %>: Handlebars.template(<%= fn %>),

I can't make a PR on this PR... so I guess I'll just comment here ;-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ocke, yep

I only began testing when I first put it up, realised there was a call missing, then moved onto something else 😸

Thanks for the comment, much appreciated

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well now you know I tried your code ;-). I actually programmed this thing myself, not realizing you did it already.

I used npm and .bin/handlebars #{file} though. But I like your approach more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably saw, in the PR description, I considered that, as an enhancement, it might be better to precompile the templates out to a file to be cached in S3, rather than precompiling every time.

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

Successfully merging this pull request may close these issues.

None yet

2 participants