gerboards.blogg.se

Using jquery ajax in pug template
Using jquery ajax in pug template









copy the template and add it to the page On document load, read your template and tokenize it using a simple String#split var itemTpl = $('script').text().split(/\$\,Ĭonst template = $("template#example").contents() Ĭonst templateTitle = template.find("h1.title") Ĭonst templateDescription = template.find("p.description") One property you can rely on for keeping the HTML for your template next to the rest of your HTML, is by using a non-executing type, e.g. what we see with properties mapped to components in ReactJS (especially stateless components). Modern templating practices encourage simply mapping an object to its DOM (or other) representation, e.g.

using jquery ajax in pug template

While there are a lot of templating engines out there, many of their features have fallen in to disfavour recently, with iteration ( ) seen as microlanguage at best, and anti-patterns at worst.

using jquery ajax in pug template

Old question, but since the question asks "using jQuery", I thought I'd provide an option that lets you do this without introducing any vendor dependency.











Using jquery ajax in pug template