I am looking to create a variable that is a template for repatative elements of my site. I however am only using it infrequently so I do not wish to use a javascript templating engine or library.
I am using jquery… if that effects anyones approach.
This is one of my templates.
$html_template = json_encode("
var html = '<a href=\"javascript:ajax(\'#content\',\'{$conf['dir']['web_url']}profile.php?user_id='+data.id+'\');\">
<div id=\"'+data.id+'\" class=\"fb_user\">
<img alt=\"'+data.name+'\" height=\"50\" width=\"50\" />
<p>
'+data.first_name+'
<br/>
'+data.last_name+'
</p>
</div>';");
I have gotten so lost in escaping I can’t work out where I have gone wrong. The plan is to use eval within the templating function to replace the variables.
Hope someone can help
1 Answer