Anyone have any clean patterns for getting php vars into the js scope?
Two ways I have done it before is either injecting it with an actual call from the base template inside a document ready wrapper.
(jQuery/Smarty Template)
{literal}
$(document).ready(function() {
TargetClass.targetVar = {/literal}{$phpVar}{literal};
});
{/literal}
Also setting it to a tag and pulling that from the DOM once the JS executes.
HTML
<link id="phpVar" value="{$phpVar}" />
JS
var phpVar = $('#phpVar').attr('value');
.
Have any of you found a better method?