Jozko Golonka
Jozko Golonka

Reputation: 323

Php - replace question mark sign

Is it possible to replace php tags to something custom?

Smarty library can assign values and then render them so instead of:

<?php echo $name; ?> 

you can just assign value in business logic and then in template just say

{name} 

I'd like to make my own function/class/library so when I write { in index.tpl, browser will think its < ?php echo ..

Can somebody point me somewhere?

Upvotes: 0

Views: 198

Answers (1)

Michal Hatak
Michal Hatak

Reputation: 787

replace {variable} with regexps and then eval-it

here is simple template engine, very similar to your idea

i mean, better is use existing templates engines, like Latte, Twig or Smarty. Its not necessary reinventing wheel :)

Upvotes: 2

Related Questions