Skip to main content
added 5 characters in body
Source Link
yglodt
  • 14.4k
  • 15
  • 98
  • 135

You can also do like this, which is the most compact I guess:

In your @Controller:

model.addAttribute("items", new String[] { "item1", "item2", "item3" });

In your template:

<script type="text/javascript" th:inline="javascript">

var items = [];

/*[# th:each="n : ${items}"]*/

items.push("[(${n})]");

/*[/]*/

</script>

Other useful stuff is explained here: [MAJOR FEAT] New syntax for textual template modes #395

You can also do this, which is the most compact I guess:

In your @Controller:

model.addAttribute("items", new String[] { "item1", "item2", "item3" });

In your template:

<script type="text/javascript" th:inline="javascript">

var items = [];

/*[# th:each="n : ${items}"]*/

items.push("[(${n})]");

/*[/]*/

</script>

Other useful stuff is explained here: [MAJOR FEAT] New syntax for textual template modes #395

You can also do like this, which is the most compact I guess:

In your @Controller:

model.addAttribute("items", new String[] { "item1", "item2", "item3" });

In your template:

<script type="text/javascript" th:inline="javascript">

var items = [];

/*[# th:each="n : ${items}"]*/

items.push("[(${n})]");

/*[/]*/

</script>

Other useful stuff is explained here: [MAJOR FEAT] New syntax for textual template modes #395

deleted 1 character in body
Source Link
yglodt
  • 14.4k
  • 15
  • 98
  • 135

You can also do this, which is the most compact I guess:

In your @Controller:

model.addAttribute("items", new String[] { "item1", "item2", "item3" });

In your template:

<script type="text/javascript" th:inline="javascript">

var items = []; 

/*[# th:each="n : ${items}"]*/
     
items.push("[(${n})]"); 

/*[/]*/

</script>

Other useful stuff is explained here: [MAJOR FEAT] New syntax for textual template modes #395

You can also do this, which is the most compact I guess:

In your @Controller:

model.addAttribute("items", new String[] { "item1", "item2", "item3" });

In your template:

<script type="text/javascript" th:inline="javascript">

var items = [];
/*[# th:each="n : ${items}"]*/
    items.push("[(${n})]");
/*[/]*/

</script>

Other useful stuff is explained here: [MAJOR FEAT] New syntax for textual template modes #395

You can also do this, which is the most compact I guess:

In your @Controller:

model.addAttribute("items", new String[] { "item1", "item2", "item3" });

In your template:

<script type="text/javascript" th:inline="javascript">

var items = []; 

/*[# th:each="n : ${items}"]*/
 
items.push("[(${n})]"); 

/*[/]*/

</script>

Other useful stuff is explained here: [MAJOR FEAT] New syntax for textual template modes #395

Source Link
yglodt
  • 14.4k
  • 15
  • 98
  • 135

You can also do this, which is the most compact I guess:

In your @Controller:

model.addAttribute("items", new String[] { "item1", "item2", "item3" });

In your template:

<script type="text/javascript" th:inline="javascript">

var items = [];
/*[# th:each="n : ${items}"]*/
    items.push("[(${n})]");
/*[/]*/

</script>

Other useful stuff is explained here: [MAJOR FEAT] New syntax for textual template modes #395