Handling ember.js with html tags with python

I have the following script:

To do this, I need to change all instances {{XXX}}in ember.js files to {{= em ('XXX')}}, including instances that span multiple lines. I'm considering renaming a regex here, but I would like to not reinvent the wheel (and deal with corners of others)

Can you introduce a generic method in python to parse such patterns. You just need to look for the start and end delimiter ( {{and }}) and place =em('XXX'), to handle newline characters and store format (ie Save newline, if any).

Note: this is actually not a specific ember.js; It can be applied to any multi-line template system.

+3
source share
2 answers

, tr2 web2py ( web2py 2.0 ) - web2py, ember.js. , :

response.delimiters = ['{%', '%}']

web2py :

{%=P('hello world')%}
<p>{{ember template code}}</p>
{%=P('{{ember template code generated by web2py}}')%}

:

<p>hello world</p>
<p>{{ember template code}}</p>
<p>{{ember template code generated by web2py}}</p>

. response response.delimiters , , web2py , , ember, response.delimiters ( , , / ). , :

if request.function in ['action1', 'action2', 'action3']:
    response.delimiters = ['{%', '%}']

:

def action1():
    response.delimiters = ['{%', '%}']
    [etc.]
+3

, , Ember.js web2py. , Ember.js .

0

All Articles