Pinegrow with Template Engines (Handlebars, Mustache, etc)

I’ve adopted Pinegrow as my go-to front-end design tool, and have been using it with mustache so far.

There was an issue with Pinegrow autocorrecting and removing some of the vital syntax:
ie: Pinegrow would remove all the / 's from any template code : {{/payload}} for example, and leaving it looking like this: {{ payload}}

I’ve had to develop a work around “fix” function in my workflow prior to template rendering and sending back to the client a response,

Here is a sample of my “fix” code for anyone who may be experiencing the same situation.

msg.payload = msg.payload.replace(/{{ /g, "{{/")
msg.payload = msg.payload.replace('{{="" ', "{{/");
msg.payload = msg.payload.replace('}}=""', "}}/");

Basically the msg.payload contains the whole HTML with the templating code,
When Pinegrow saves, it takes out the / as stated, and then when my server loads this code, it works by doing this “fix”, by looking for bare brackets without the slash, and then replacing them with the slash in tact.

I’ve been happy with the outcome of this until recently where I’m stuck in a situation where all my menus / navbar are dynamically loaded (by means of a rendered mustache template inside a Pinegrow navbar component), which works fine, until I try to do client side rendering of these templates.

My problem is when I have a <template> of HTML, that too gets rendered, and those template placeholders get rendered out of view from the server side rendering. I remove the server side rendering, and opt for a client side, but then my dynamic menus are compromised.

I’ve noticed some pug capabilities with Pinegrow, though I’ve not explored them, as I’ve not dove into pug, though I imagine it’s easy to grasp, I’d need to update a lot of template code if I went that route.

I don’t want this thread to turn into a multi-topic post, so I just want to share my “fix” and was just curious if anyone experienced my situation.

@mrSidX is this still happening in PG? As far as I can test the “/” is not removed.

1 Like

Hey Matjaz,

Sorry for late reply.

It is still removing the “/” on my end. I’ve checked the settings so PG doesn’t modify the html. I’m not sure the setting addresses on this handlebars syntax?
Granted, I need to upgrade to the latest version, as I’m still on version 6.x something. :frowning:

I appreciate your followup, Matjaz.

I have moved most of the template rendering onto the client side via use of a javascript function containing and returning the result of the above “fix” code. Now I am able to correct for the missing / 's in the returning template code.

I am assuming you are working with version 7.x.x which leaves the handlebars syntax intact?