I have the following scenario:
- We are using web2py in the server side
- We are serving some ember.js pages
- Currently those ember.js pages are inside an iframe, because ember.js and web2py conflict with template {{ }} marks. That means we can not easily mix web2py templates and ember.js templates.
- So I have implemented the helper class solution:
class em(DIV)
- Now I want to process the original ember-tagged html files, and produce the em-tagged files, integrating ember.js and web2py templating-systems into a cohesive unit.
For that I need to change all instances of {{XXX}}
in the ember.js files to {{=em('XXX')}}, including instances which span over several lines. I am thinking of going regex here, but I would like to avoid reinventing the wheel (and having to handle strange corner-cases)
Can you think of a generic method in python of parsing these kind of templates. It is simply a matter of looking for start and end delimiter ({{
and }}
), and putting an =em('XXX')
, handling newlines, and keeping the format (that is, keep the newlines if there are some).
Note: this is actually not ember.js specific; it could apply to any multi-line delimiter-based templating system.
em
helper class), to use a different delimiter for ember.js (I do not have ember.js legacy). I do not know if that is configurable, I will investigate. – Arbor