Reputation: 1147
I am using mustache PHP to render my html files and everything works correctly except in one case. There is a situation where I load an html file through an ajax call following this structure:
PHP - renders -> HTML - javascript appends -> HTML 2nd file
What I would like to do is to get the mustache parameters into the HTML 2nd file, as some data is generated in the initial PHP file and I wouldn't like to make another call to retrieve this data again.
What I can do is to insert hidden inputs to get the data from them in javascript but I would really like to avoid this practice. I don't like this practice as user can easily modify the inputs.
Any idea??
Upvotes: 3
Views: 1157
Reputation: 1147
At the end I found a solution for this. Print the output of a php file on an ajax call.
Mustache_Autoloader::register();
$m = new Mustache_Engine(array(
'loader' => new Mustache_Loader_FilesystemLoader('./templates/')
));
echo $m->render('templatename', $o);
and then using .html(data); with jQuery
Upvotes: 2