I'm loading a template file into a div using jquery and populating in the example below "%FIRST_NAME%" with the first name from my $user_data object. Works fine.
Problem is, I have about 10 or so different variables to insert into the template (vehicle, address etc. etc.) What Im wondering is what is the 'right' or condensed way of doing it? Only way I can think of is repeating a few of the lines over and over somehow. Is there a smart way of doing this?
$template = file_get_contents($template_url);
$pattern = '%FIRST_NAME%';
$replacement = $user_data->first_name;
$rendered_template = preg_replace($pattern, $replacement, $template);