[JSMODELS-17] Enable load function of Magnolia resource Created: 14/Aug/17  Updated: 24/Aug/17  Resolved: 22/Aug/17

Status: Closed
Project: Magnolia Javascript Models
Component/s: None
Affects Version/s: 1.0
Fix Version/s: 1.0

Type: Improvement Priority: Neutral
Reporter: Christoph Meier Assignee: Jaroslav Simak
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Date of First Response:
Sprint: Kromeriz 110
Story Points: 3

 Description   

In a JavaScript model you can load other js files which define other JavaScript classes.
Currently it works like this:

load(__PATH__ + "/../js/utils.js");

The _PATH_ variable is evaluated by the system, it is the path of the script (which calls load) on the file system.

This is breaking the concept that a JS model can be any Magnolia resource (currently a Magnolia resource can be from the file system, from classpath or a file representation in a JCR node).

An improved version should support something like this:

 loadScript('/path/to/resource/in/our/resource/origin')

e.g.

 loadScript('/javascript-model-samples/templates/js/formProcessors/saveContact.js')


 Comments   
Comment by Roman Kovařík [ 22/Aug/17 ]

For the record: it's possible to create cycle with loadScript() resulting into a stackoverflow error.

Comment by Jaroslav Simak [ 24/Aug/17 ]

cmeier
I'm sorry, i forgot to update description of the ticket - new function is called loadScript (instead of loadResource). The load function still works only the "old" way.

Comment by Christoph Meier [ 24/Aug/17 ]

yep - like this it works

Generated at Mon Feb 12 05:58:49 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.