pug

jade html escaped string

a 夏天 提交于 2019-12-14 03:03:48
问题 I have a problema with Jade, I take an unescaped string from db (something like this: "<mo>&amp" this string can contain some html code, I pass the string to the page with res.render('page',f(){}) from the layout I stamp the string with !{t.text} but the html code is not rendered, seems that prints plain text. where is the error? 回答1: I've set up default express app which uses jade as its template engine. Modified routes -> index.js to pass some encoded text router.get('/', function(req, res)

How do I prevent Pug from collapsing all whitespace between two tags?

回眸只為那壹抹淺笑 提交于 2019-12-13 23:33:06
问题 When I do this in a template: div(class="field") label Password input(type="password") I get this output: <div class="field"><label>Password</label><input type="password"></div> So the label and input tags have zero space between them, instead of the single space between them that they would have in a normal HTML file where they're on two different lines. How do I get that standard single space between the two elements, in a Pug template, in the least ugly possible way? I could use CSS to fix

Reading environment variables from pug

孤者浪人 提交于 2019-12-13 17:16:14
问题 I'm using pug to compile static html. My own static site generator, kinda. I have no node.js server code besides this line in my package.json file: "watch-pages": "pug -O options.json -w pages/ --out _static-website/" But, I need to read environment variables like NODE_ENV inside of pug templates. How might I do this? 回答1: This is fairly simple; you may find another way to do it but what I tried (successfully) was to simply define a .js file to pass as the options parameter which includes the

in Jade, why can i sometimes use variables as-is and on other times have to enclose them in #{…}?

旧城冷巷雨未停 提交于 2019-12-13 16:37:24
问题 Look at the below code for story in book if story.title.length < 140 - var storyTitle = story.title; else - var storyTitle = story.title.substring(0, 140) + '...'; .tiles a(href= 'http://' + story.link) img(src=story.thumbnail, width='150', height='150') p Title: #{storyTitle} p Date: #{story.time} p Author: #{story.authorName} This is working for me. However it perpllexes me that at tmes I can get away with using story.attribute and at places i must use #{story.attribute}. For eg. if i use

How to use jade mixins on client side

南笙酒味 提交于 2019-12-13 13:18:32
问题 We can compile jade template as an anonymous function and call it when we need to render it on client side. What about mixins? mixin: mixin tiny(text) button.tiny #{text} 回答1: You can use them like this: Declare your mixin somewhere, then use + to call it when you want and pass the parameters in. mixin person(name) // Declare li.name= name ul +person('cat') // User +person('dog') +person('pig') In your example mixin tiny(text) // Declare button.tiny= text +tiny('text') // Use 来源: https:/

Angular-ui router loading jade template

人盡茶涼 提交于 2019-12-13 12:09:46
问题 I'm trying to combine Express with Angular and notably Angular-UI Router and use Jade: My index.jade looks like this: doctype html html(lang="en") head meta(charset='UTF-8') meta(name='fragment', content='!') base(href='/') title Node Express Angular Example meta(name='viewport', content='width=device-width, initial-scale=1.0') link(rel='stylesheet', href='//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css') link(rel='stylesheet', href='./css/style.css') body(style='', ng-app=

How to render array of array of objects in Jade

偶尔善良 提交于 2019-12-13 10:06:37
问题 I have a an array like: [ a: [ { "id" : "1" "val" : "sharedVal1" }, { "id" : "2" "val" : "sharedVal1" }, ] b: [ { "id" : "3" "val" : "sharedVal2" }, { "id" : "4" "val" : "sharedVal2" }, ] c: [ ... ] ] How can I render this in Jade? My current attempt looks like each city in cities h2 asdf each foo in city .col-md-4 .row.bottomPadding .col-md-3 img(src='#{foo.logo_image_url}') .col-md-9.text-nowrap p.nav.hide-overflow #{foo.name} Nothing is rendering currently. If I just pass in the flattened

how do I write jade-style html with an angular app? [closed]

天涯浪子 提交于 2019-12-13 09:56:15
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I started writing an express app and really liked using Jade for my html. Now I'm writing an angular app and don't want to type all of the "<>" for my html. I haven't decided on a backend for the angular app. How do I write the html for an angular app using jade? Edit: I made a package.json and included:

tabblable inside tabbable twitter bootstrap

筅森魡賤 提交于 2019-12-13 08:21:21
问题 im making my admin panel... with many forms that i want to clasify by category so im trying to do something like this div.tabbable ul#first-tab.nav.nav-tabs li.active a(href='#datos-de-usuario',data-toggle='tab') Datos de usuarios li a(href='#datos-de-comercio',data-toggle='tab') Datos de comercio div.tab-content div#datos-de-usuario.tab-pane.active div.tabbable.tabs-left ul#second-tab.nav.nav-tabs li.active a(href="#formulario-nuevo-usuario") Nuevo usuario li a(href="#formulario-borrar

How to use for loop including files in jade (pug)?

為{幸葍}努か 提交于 2019-12-13 08:19:00
问题 I would like to use a for loop to include jade files each after the other such as slide-1, slide-2, slide-3 etc. I tried this but it failed: for(var i = 1; i < 4; i++) { include('slide-' + i) } What's the correct syntax? Thank you in advance! 回答1: If you need to iterate a certain number of times, you'd need to define your own function to do so. html title Whatup -function range(start, end) { - var arr = []; - for (var i = start; i < end; i++) arr.push(i); - return arr; - } each i in range(1,