Xarigami

project tracker

Xarigami Core [key: xgami]

All trackers
Summary
Issue List
Road Map
Changelog

Issue xgami-000843

Issue summary Details
Project:
Xarigami Core
Key:
xgami-000843
Type:
New feature
Reporter:
Jo
Priority:
Urgent
Severity:
Major
Status:
Closed
Resolution:
Implemented
Owner:
Jo
Due:
- xarigami cumulus 1.4.0
Milestone:
None

solve js template dirty markup and unescaped variables

Reported:  Apr 29, 2011 06:46 AM    Updated: Mar 19, 2012 02:08 PM by

Closed: Mar 19, 2012 02:08 PM    by Jo

Version affected: - xarigami cumulus 1.3.5

This is a more general problem, given we have to add the js code snippets in templates.

1. The template js markup has to be doctored to pass the BL compiler, or accept xarML functions, or for other issues so writing clean js is not an option

2. Getting variables into the JS for example with xarML means we also have to add slashes making the js code even more unreadable.

Ideally we want a simple way to have the js code written nicely and easily put our variables into the js code, and have them with addslashes where needed.

This is urgently needed, but only of major severity due to the number templates we probably need adjusting with any given solution.

Actions

A solution for trial is to:
1. Move the code out of the templates into a file, written up normally as clean javascript.

2. Pass in the variables by adding them in a serialized $options array to the javascript tag.

3. This options array is adjusted in the js.class, and is json encoded enabling adding of slashes where appropriate, and the variables then added in a small js snipped automatically to the template, just before the js file they relate to, a comment just before the js tag provides the link to the file they related to.

Currently this is only added to the base-add-javascript type="src" as it is for code moved out of the templates into a file when we need to pass options.

While we have places in core where we should apply this, i'm closing this issue now as the mechanism for test solution has been added.

#

Example of use: Jo Apr 29, 2011 07:04 AM

See Articles module admin-view.xd
- there is an included js file rather than included template.
- note the serialized array passed in the add-javascript tag for the file.

#

This unfortunately, is only a simple and part solution for some specific cases. Full solution is still in the making

#

Added for inline js Lakys Sep 5, 2011 04:13 PM

In the case the attribute code="$yourcode" is used to create inline javascript code, now the serialized array 'options' attribute can also be passed.

This is a really recent implementation available in the latest Core 1.4.0 builds.

#

Temporary solution. full solution to be implemented in 1.5.0

#