pug

Applying nested object of attributes in Jade/Pug

别等时光非礼了梦想. 提交于 2019-12-19 21:49:09
问题 Is there a way to pass an object of data/aria attributes to an element? I've tried: div(data={foo:'bar'}) div(data={foo='bar'}) div&attributes({aria:{foo:'bar'}}) But none of these output the desired attribute notation. The first and third place an object literal in the base data/aria attribute. The second is a syntax error. The only ways that I can find that work are: div(data-foo='bar') div&attributes({'aria-foo':'bar'}) 回答1: By leading new lines with a minus - you are able to write regular

Applying nested object of attributes in Jade/Pug

瘦欲@ 提交于 2019-12-19 21:47:03
问题 Is there a way to pass an object of data/aria attributes to an element? I've tried: div(data={foo:'bar'}) div(data={foo='bar'}) div&attributes({aria:{foo:'bar'}}) But none of these output the desired attribute notation. The first and third place an object literal in the base data/aria attribute. The second is a syntax error. The only ways that I can find that work are: div(data-foo='bar') div&attributes({'aria-foo':'bar'}) 回答1: By leading new lines with a minus - you are able to write regular

Pug/ Jade - input is a self closing element: <input/> but contains nested content?

烂漫一生 提交于 2019-12-19 14:16:35
问题 I want to create the html like this: <label class="radio-inline"> <input type="radio" name="hidden" checked="" value="Visible"> Visible </label> Pug/ Jade: label.radio-inline input(type="radio", name="hidden", value="0", checked="") Visible But I get an error: input is a self closing element: but contains nested content. What does it mean? How I can fix this? 回答1: There are multiple ways to do that using Jade / Pug. The first way is to use a pipe char (which requires a new line): input | text

Pug/ Jade - input is a self closing element: <input/> but contains nested content?

点点圈 提交于 2019-12-19 14:12:44
问题 I want to create the html like this: <label class="radio-inline"> <input type="radio" name="hidden" checked="" value="Visible"> Visible </label> Pug/ Jade: label.radio-inline input(type="radio", name="hidden", value="0", checked="") Visible But I get an error: input is a self closing element: but contains nested content. What does it mean? How I can fix this? 回答1: There are multiple ways to do that using Jade / Pug. The first way is to use a pipe char (which requires a new line): input | text

Pug/ Jade - input is a self closing element: <input/> but contains nested content?

徘徊边缘 提交于 2019-12-19 14:12:44
问题 I want to create the html like this: <label class="radio-inline"> <input type="radio" name="hidden" checked="" value="Visible"> Visible </label> Pug/ Jade: label.radio-inline input(type="radio", name="hidden", value="0", checked="") Visible But I get an error: input is a self closing element: but contains nested content. What does it mean? How I can fix this? 回答1: There are multiple ways to do that using Jade / Pug. The first way is to use a pipe char (which requires a new line): input | text

AngularJS and Express Routing issue

自古美人都是妖i 提交于 2019-12-19 11:51:52
问题 I'm using AngularJS and ExpressJS and having an issue with routing. I saw many other posts but none of those solutions seemed to work. Here is my routes in Express: module.exports = function(app, auth) { //Api routes var mycontroller = require('../app/controllers/mycontroller'); app.get('/api/dostuff/:id', mycontroller.getBlockByHash); //Home route app.get("/", function(req, res) { res.render('index'); }); }; When I go to my root / , everything works as expected. ExpressJS serves up my index

Jade - way to add dynamic includes

杀马特。学长 韩版系。学妹 提交于 2019-12-19 05:23:35
问题 I'd like to do something like the following within a jade template. include page-content/#{view.template} As this won't work I have ended up with. -if(view.path==="/") include ../page_content/home -else if(view.path==="/login/") include ../page_content/login -else if(view.path==="/join/") include ../page_content/join -else if(view.path==="/user/") include ../page_content/user ad nauseum I asked TJ whether it was possible, he replied unfortunately no, they're compile-time includes, which is

Writing dynamic CSS with Jade

那年仲夏 提交于 2019-12-19 05:17:11
问题 I'm trying to write out some dynamic CSS using Jade, like so: style(type='text/css') each item in colors .#{item.class} { background-color : #{item.background}; color: #{item.foreground}; } However this gives the following error: ReferenceError: media='print') 7| style(type='text/css') > 8| - for(var item in colors) 9| .#{item.class} { background-color : #{item.background}; color: #{item.foreground}; } 10| block Content 11| include scheduleTemplate item is not defined If I remove the style

Multi-Line Array Literal

ぃ、小莉子 提交于 2019-12-18 15:12:28
问题 In my Jade template, I'm trying to make an array like so: - var myArray = [ 'one', 'two', 'three' ] But it doesn't compile. Anyone know why? Being able to have a multi-line array that I can use as a mixin argument would make my code much less verbose. 回答1: - myArray = ['one'] - myArray.push('two') - myArray.push('three') If you wanna. 回答2: You can use block code: - var myArray = [ "one", "two", "three" ] each row, index in myArray 回答3: You can't do that :( https://github.com/visionmedia/jade

Multi-Line Array Literal

孤者浪人 提交于 2019-12-18 15:12:21
问题 In my Jade template, I'm trying to make an array like so: - var myArray = [ 'one', 'two', 'three' ] But it doesn't compile. Anyone know why? Being able to have a multi-line array that I can use as a mixin argument would make my code much less verbose. 回答1: - myArray = ['one'] - myArray.push('two') - myArray.push('three') If you wanna. 回答2: You can use block code: - var myArray = [ "one", "two", "three" ] each row, index in myArray 回答3: You can't do that :( https://github.com/visionmedia/jade