Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving Jaws_Template #9

Open
afz opened this issue Oct 12, 2012 · 1 comment
Open

Improving Jaws_Template #9

afz opened this issue Oct 12, 2012 · 1 comment
Labels
Milestone

Comments

@afz
Copy link
Member

afz commented Oct 12, 2012

  • loop support for multi dimensional array
  • template cache support
  • plugin support
@mkhahani
Copy link
Member

Currently we define JavaScript global variables in html templates and set them by php setVariable() function. So the developer has to set them twice(html and php) and when changing, thrice(html, php, js). Moreover we may have many variables that make the template dirty.

I think we should set them in a single variable for example CONST that is an array of those variables. A simple implementation may looks like this:

PHP:

$const = array();
$const['variable_x'] = _t('X_VARIABLE');
$const['variable_y'] = _t('Y_VARIABLE');
..
$tpl->SetVariable('CONST', json_encode($const));

Template:

var CONST = eval("({CONST})");

Javascript:

alert(CONST.variable_x);

So we have just single line of code in our template and can manage variables easily.
An enhancement is to move them to the core and define variables by an API like this:

$GLOBALS['js']->AddVariable('variable_x', _t('X_VARIABLE'));

and no codes in template!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants