Skip to content

Commit 5229fb7

Browse files
committed
2 parents 4dcd802 + 2e56c06 commit 5229fb7

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
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+
```

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<dependency>
4242
<groupId>junit</groupId>
4343
<artifactId>junit</artifactId>
44-
<version>4.11</version>
44+
<version>4.13.1</version>
4545
<scope>test</scope>
4646
</dependency>
4747
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->

0 commit comments

Comments
 (0)