Skip to content

Commit 2e56c06

Browse files
authored
Update README.md
1 parent e5d3570 commit 2e56c06

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,3 +279,33 @@ console.log("${message}");
279279
return "view";
280280
}
281281
```
282+
### Javascript multi modules resource
283+
To avoid the multiplicity of javascript files, it is possible to group several scripts in the same file.
284+
285+
Each script (qualified as a module) must be identified in the javascript file by a comment on a single line bearing its name, and a comment marking the end (also mentioning the name of the script).
286+
287+
#### resource/static/js/multi.js
288+
Each script can possibly be isolated, which is without consequences.
289+
290+
```javascript
291+
//resource/static/js/multi.js
292+
//----------------consoleMsg-----------------------
293+
console.log("${message}");
294+
//----------------consoleMsg (end)-----------------
295+
296+
//----------------alertMsg-------------------------
297+
(function(){
298+
alert("${message}");
299+
})();
300+
//----------------alertMsg (end)-------------------
301+
```
302+
#### In the java controller
303+
```java
304+
@GetMapping("sample")
305+
public String testJsMulti(@ModelAttribute("vue") VueJS vue) throws IOException {
306+
JavascriptMultiModulesResource jsMulti=JavascriptMultiModulesResource.create("multi");
307+
jsMulti.getModule("consoleMsg").put("message", "This is a console message");
308+
vue.addMethod("click", js.parseContent("consoleMsg"));
309+
return "view";
310+
}
311+
```

0 commit comments

Comments
 (0)