简体   繁体   中英

Import mustache Template using parameters Java Spring MVC

I need to make something like this using Mustache and Spring MVC:

{{> /WEB-INF/views/'{{content}}'.html}} 

Where {{content}} is an object from Spring MVC:

model.addObject("content", "home");

Did you try adding this character?

 {{#content}}

Here you have a very good example about how to integrate Spring MCV with mustache http://java.dzone.com/articles/integration-spring-mvc-and-0

Basically the expression which you're using "{{> partial name }}" is used to include a mustache partial within another mustache template. Where, a partial is nothing but a Mustache template that can be included/imported within another template.

So for instance, if you have 2 Mustache templates

  1. main.mustache
  2. home.mustache Then, your 'main.mustache' will have code like this:

     {{#content}} {{> /WEB-INF/views/home.html}} {{/content}}

FYI, Mustache manual - https://mustache.github.io/mustache.5.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM