Is it possible to pass HTML elements into a jade file e.g. I would like for the following to populate the p element with text, and a code element with some contained text nested inside the p element.

JSON containing strings

var news = {
  one : {
    title : "Using JSON",
     body : "Using JSON is a great way of passing information into the jade template files."+
            "It can be looped over using jades each syntax <code>test</code>"
  },
  two : {
    title : "",
    body : ""
  }
}

Routing the HTTP request

// Routes
app.get(navigation.home.uri, function(req, res){ //Home
  res.render(navigation.home.url, {
    title: navigation.home.title,
    navigation: navigation,
    news: news
  });
});

Jade file snippet, with a loop for each news item

  section#news
    - each item in news
      article(class="news")
        header
          h2 #{item.title}
        p #{item.body}

没有正确的解决方案

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top