Templating variables as html data-* attributes?

10 views
Skip to first unread message

Joel Beasley

unread,
Feb 27, 2016, 6:54:42 PM2/27/16
to Guardians of the Temple
I have a rails app that currently uses Liquid template to generate reports that can then be edited in a WYSIWYG editor by a user.

Now, the need has come up to keep the variables within the generated/editable html report in sync with changes from the application; and since {{money}} has been converted to $1,000 I have lost track of this information and have no ability to update it.

My first idea is to use html tags so I can "reprocess" the html and update accordingly.

Ex: <section data-variable="money"></section> instead of {{money}}

Has anyone done something like this before, or do you know of any projects out there or a different strategy?

Any information is greatly appreciated.

Thanks,

Joel

Bryan Powell

unread,
Feb 27, 2016, 11:38:58 PM2/27/16
to guardians-o...@googlegroups.com
You might look at Pakyow (https://pakyow.org) for inspiration. It's built around this very idea, using data-scope and data-prop to represent types and attributes of application data in the html view. This knowledge is used for both initial rendering and subsequent updates as application state changes. Disclaimer: I wrote Pakyow and am one of its core maintainers.

Bryan P.

_____________________________
From: Joel Beasley <jbeasl...@gmail.com>
Sent: Saturday, February 27, 2016 5:54 PM
Subject: Templating variables as html data-* attributes?
To: Guardians of the Temple <guardians-o...@googlegroups.com>
--
You received this message because you are subscribed to the Google Groups "Guardians of the Temple" group.
To unsubscribe from this group and stop receiving emails from it, send an email to guardians-of-the-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Reply all
Reply to author
Forward
0 new messages