pug

Using AJAX with express (changing variables after request)

冷暖自知 提交于 2019-12-24 00:39:32
问题 I want to make a single page app. simplification of what I want: First on "/" will be a home page with a display section with 2 buttons. when they click on button 1 we will retrieve data from server and display it on the page in the display section and do the same thing for button 2 but for different data. I'm having a hard time grasping on how to put in the right display section. I know you could do conditions in Jade like: html head script(src ="http://code.jquery.com/jquery-2.1.1.js")

Use pug mixin result as attribute value

旧街凉风 提交于 2019-12-23 22:45:45
问题 Here is a boiled-down version of what I'm trying to accomplish: mixin foo(bar) = bar + ".html" a(href= +foo("baz")) test I'd like to have the anchor tag be compiled as <a href="baz.html">test</a> , but what I'm getting instead are type errors, on foo not being a function. Although I do see that it technically isn't a function, is this not a scenario where a mixin would be useful? I've searched the pug documentation for use-case scenarios similar to mine, but without success. Is what I'm

Swipeleft/swiperight not working

旧城冷巷雨未停 提交于 2019-12-23 22:32:28
问题 I'm making a presentation for the iPad. I want to use the swipeleft and swiperight from the jquery-mobile library. At the moment I'm testing everything in google chrome. I did enable 'Emulate touch screen' My problem: I don't get a message in the console, so the swipe doesn't work. The versions I'm using: jquery : jquery- 2.1.1 .js and jquery-mobile : jquery.mobile- 1.4.5 .js $(document).ready(function(){ // Previous/next slide on swipe $('.bg, header').on('swipeleft', function(e){ console

Problems with Jade, Unexpected character #

核能气质少年 提交于 2019-12-23 18:40:14
问题 I keep getting: .../views/index.jade:20 18| alert(error) 19| }) > 20| server.on('warning',function(warning){ 21| alert(warning) 22| }) 23| var num = -1 Unexpected character # expected ' ', '\n', ',', '!' or '=' This is my jade file: extends layout block content #splash(style='z-index: 3120; position: absolute; left:0; top:0; width:100%; min-height:100%; background-color:#444;') img(src="/stylesheets/some.png", style='display:block; margin-left: auto; margin-right: auto; margin-top:10%;') div

in node.js, how to pass variables to :stylus filter from jade?

笑着哭i 提交于 2019-12-23 18:18:36
问题 creating a variable within jade that I wish the stylus filter to use. using #{var} does not appear to work. for example, this code: - var color1 = 'blue' stylus: div background-color pink color #{color1} gives resulting error: /home/data/tnt/server/node/www/tech/cool.jade:2 1| div 2| background-color pink > 3| color #{color1} 4| expected "indent", got "outdent" how do I get the jade variable color1 visible within the stylus filter? 回答1: Filters (like stylus, markdown etc.) are executed during

Can you refer to variables with dashes in jade?

妖精的绣舞 提交于 2019-12-23 15:12:59
问题 I'm trying to do something like this in my jade template a.apply-url(href="#{apply-url}") But it's being interpreted as 'apply minus url' Is there a way I can force the interpreter to do the right thing? Or is there some way to refer to a top-level object, and put the index in quotes, like this? a.apply-url(href="#{this['apply-url']}") 回答1: I'm not all that familiar with Jade, but I have looked into it a little bit before. After playing around a while here, I was able to get this to work: a

Jade Cannot read property 'length' of undefined

牧云@^-^@ 提交于 2019-12-23 12:32:28
问题 Why menuItems is undefined in the following code? - var menuItems = ["Main","Contacts","About"] mixin showItems(items) ul each item in items li: a(href="#") #{item} extend layout block content +showItems(menuItems) I get the following error: Cannot read property 'length' of undefined 回答1: - var menuItems = ["Main","Contacts","About"] mixin showItems(items) ul each item in items li: a(href="#") #{item} extends layout block content +showItems(menuItems) There is a Typo 'extends layout' 来源:

Pug call js function from another file inside template

此生再无相见时 提交于 2019-12-23 09:10:54
问题 I can't solve this for almost four hours, and i can't find any helpful documentation for this kind of problems. This is the issue, I'm using pug/jade templates and i want to call function inside pug template to transform some data This is the main template: /** main template */ section each pet in pets .pet .photo-column img(src= pet.photo) .info-column h2= pet.name span.species= (pet.species) p Age: #{calculateAge(pet.birthYear)} //here I need to call calculateAge function if pet.favFoods h4

input is self closing and should not have content

雨燕双飞 提交于 2019-12-23 07:26:53
问题 When I load my Express webpage I'm getting the following error: Express 500 Error: /app/views/index.jade:114 112| td 2 113| td 4 years > 114| input is self closing and should not have content. 112| td 2 113| td 4 years > 114| input is self closing and should not have content. at Object.Compiler.visitTag (/app/node_modules/jade/lib/compiler.js:434:15) at Object.Compiler.visitNode (/app/node_modules/jade/lib/compiler.js:210:37) at Object.Compiler.visit (/app/node_modules/jade/lib/compiler.js

Require a javascript library inside Jade

你说的曾经没有我的故事 提交于 2019-12-23 06:57:36
问题 How do I require a library so that it works inside Jade. Like if I want to be able to use CircularJSON in Jade script var object = #{CircularJSON.stringify(object)} I would basically need to define the function from that library into Jade - var CircularJSON = function(e,t){function l(e,t,o){var u=[],...//whole function which would be impractical and possibly impossible for much more complex libraries. Is there a way to somehow simply require it instead? 回答1: var myLib = require('../mylib');