[NPMCLI-137] Create JavaScript model for page and component template optionally Created: 07/Aug/17 Updated: 14/Feb/18 Resolved: 07/Dec/17 |
|
| Status: | Closed |
| Project: | Magnolia CLI |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 3.0.0 |
| Type: | New Feature | Priority: | Neutral |
| Reporter: | Christoph Meier | Assignee: | Jaroslav Simak |
| Resolution: | Fixed | Votes: | 2 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Template: |
|
| Acceptance criteria: |
Empty
|
| Date of First Response: | |
| Epic Link: | CLI v3 |
| Sprint: | Kromeriz 125 |
| Story Points: | 3 |
| Description |
FeatureWith the introduction of the JavaScript Models module - models can be used in light-modules, the JS syntax makes them well suitable for frontend developers. The commands create-page and create-component should be able to create a JS model optionally. SolutionOn the template definition add this line: modelClass: info.magnolia.module.jsmodels.rendering.JavascriptRenderingModel Create an additional file in the same directory as the template def. and script are created. File name must be <template-name>.js. /** * Define properties and methods which can be accessed on the template script.<br/> * You can use Magnolia rendering context objects content, def, ctx, state, i18n.<br/> * For further info see https://documentation.magnolia-cms.com/display/DOCS/JavaScript+Models+module.<br/> */ var Foobar = function () { this.getRandomNumber = function () { return Math.random(); } }; new Foobar(); EDIT: |
| Comments |
| Comment by Tomáš Gregovský [ 07/Aug/17 ] |
|
yes! yes! yes! |