B
B
Banny_Boom2015-06-05 12:39:22
PHP
Banny_Boom, 2015-06-05 12:39:22

How to escape (Template Engine)?

I'm starting to disassemble the template engine in order to write my own one for my needs ...
I ran into the problem of escaping <?php and ?> ..
base.html - template, contains( "{% echo 'lol'; %}").
I do this:
$temp = file_get_contents(...base.html);
echo str_replace(array('{%','%}'),array('<?php','?>'),$temp);
as a result I get a commit line:
jxGYf6K.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman, 2015-06-05
@Banny_Boom

here if it’s very rude .... you need to find what is inside {% %} to execute using eval and insert the result in place of {% %} . And I'm not sure that it will work with echo

M
Maxim Grechushnikov, 2015-06-05
@maxyc_webber

why the heck template engine also your bike? php is a great templating engine! twig, haml, slim at the very worst

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question