-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
enhancementNew feature or requestNew feature or request
Description
See https://handlebarsjs.com/installation/precompilation.html#getting-started
As as starting point, npm is available on AWS Elastic Beanstalk servers. Within the initial platform setup files, we can do a simple:
sudo -u webapp npm install handlebars
This will ensure that handlebars is available to the webapp user that Rails runs under.
In the page code where we currently render the Handlebars templates, we should :
- generate a filename prefix using a partial_cache_key that doesn't use any current_user or current_admin parts (the result should be common to all users)
- for each Handlebars template
- render a javascript_include_tag to tell the browser to load a Handlebars compiled Javascript file
- check if the Handlebars compiled file already exists in a
handlebarssubdirectory of the Rails public directory - if it does, just move on to the next one
- otherwise, have the Handlebars templates render to an HTML file using the filename prefix
- run a bash script that:
- calls the handlebars command line with the input HTML filename and output compiled filename we generated
- moves the generated output file to the
handlebarssubdirectory of the Rails public directory
- in an initializer, we should
- create the handlebars subdirectory if needed
- delete any files from the handlebars subdirectory older than 24 hours
NOTE: we should check the Rails partials that generate the Handlebars templates, to ensure they don't contain any other markup. If there is anything else (I know of one place where there is an inline <script> tag) then we should move that markup outside the partial into the calling page.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request