pug

Is there a Jade template syntax checker/validator?

南笙酒味 提交于 2019-12-03 17:09:32
问题 I have some syntax errors in my Jade templates. Are there any tools that can help me debug? 回答1: Found it. Use jade [fileName].jade to debug your Jade template. You can install the Jade tool with npm install jade --global . 回答2: Adding this here because I still had to google. npm i -g pug-lint NOTE: jade has changed its name to pug 回答3: web storm is a better tool for jade development ,it idents and corrects jade files 来源: https://stackoverflow.com/questions/14173144/is-there-a-jade-template

Express, Jade, & NodeJS: Navigate between pages

早过忘川 提交于 2019-12-03 17:01:22
How do I create a Jade page that has two buttons where each one of them redirects to another page made with Jade? This is the code I made for your question: server.js var express = require('express'); var path = require('path'); var app = express(); app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'jade'); app.get('/', function(req, res){ res.render('layout', { title: 'Home' }); }); app.get('/newpage', function(req, res){ res.render('anotherpage', { title: 'Home' }); }); app.listen(3000); page1.jade doctype html html head title= title body p hi there! button(onclick=

how to have use own jade file for webpack?

爷,独闯天下 提交于 2019-12-03 16:19:09
I'm new to webpack and trying to figure out how to use my own html file in the webpack-dev-server, as well as my webpack build. in my app.js I have: require('!jade!index.jade') but that does not make an index.html as I would expect. Instead, it seems at best I can get a string output of my html, which isn't what I want: var jade = require('!jade!index.jade') jade() //outputs my html How do I get it to output an index.html file? How do I get the webpack-dev-server to use that html file? I should also mention my jade file will likely reference stylus files I use jade-html-loader with the

Pass variables to base layout from extending pug/jade template

情到浓时终转凉″ 提交于 2019-12-03 14:48:48
问题 I would like to set a class on the body tag by declaring a variable in a template that extends a base layout. When I try, the body_class variable is undefined in the layout. It appears the layout is executed before the extending template, or they are executed in different scopes or something. Is there another way? Would a mixin work here? _layout.jade: doctype html html(lang="en-au") head meta(charset="utf-8") block css body(class=(body_class || "it-did-not-work")) block header block content

AngularJS ui-router : Could not resolve___ from state ___ Error

微笑、不失礼 提交于 2019-12-03 14:41:13
问题 I am following along on this year old ui-router tutorial http://txt.fliglio.com/2013/05/angularjs-state-management-with-ui-router/ and I'm getting the following error: Error: Could not resolve 'settings/quotes' from state 'settings' I am fitting this tutorial app into my Express.JS setup and I'm using Jade for my templates. All the Jade templates seem to be rendering properly but I am noticing that there is no href being created for the User Quotes ( settings/quotes URL) ui-sref link. Maybe

How do I update A Jade Template form an ajax post?

纵然是瞬间 提交于 2019-12-03 13:55:41
I have set up a basic node.js web-app using express with the default view engine jade. When the User first loads the page the following occurs app.get('/', function(req, res){ res.render('index', { title: 'Test', mode: "user" }); }); What i cannot work out is how to then change the parameter I initially passed into the jade template from a ajax call. app.post('/', function(req, res){ console.log(req.body.list); res.redirect('back'); // I imagine the code needs to go here and look somewhat like the following // // res.?update-view({ // mode: "admin" // }); }); If anyone has had experience with

Pass variables to jade template from commandline

懵懂的女人 提交于 2019-12-03 12:52:53
I'm planning to use jade templates to generate different htmls depending on if it is in development or in production. At this time, I'm not planning to write code in node. Given this, is it possible to invoke jade from commandline and pass variables? If so, how? if, index.jade is !!! 5 html head title my jade template body h1 Hello #{name} I want to invoke it from command line passing value for name. Thank you gustavohenke You need to use the option -O / --obj within the Jade CLI. It accepts 2 type of values: Serialized JSON A path to a JSON file (this takes precedence) For example: jade -O

Recursive iteration over an object in Jade template?

↘锁芯ラ 提交于 2019-12-03 12:01:05
问题 I have an object of mixed type properties - some strings, some arrays of strings, some objects containing arrays of strings - that can potentially go many levels deep. I would like to iterate over all properties so that an object creates a div, an array creates a div, and a string property creates a span to contain the text. { "string" : "some text", "object" : { "array" : [ "text" ] } } The above object would render as: <span>some text</span> <div> <div> <span>text</span> </div> </div> But

What steps can be taken to improve jade template rendering performance in express using nodejs

痴心易碎 提交于 2019-12-03 11:41:32
Background jade syntax is awesome but i wanted to see how it was affecting performance. So i created a single page app and used apache bench to compare its throughput using jade to render a page vs using an in memory string. There were no variables so this was a purely academic comparison. The in memory string made the entire app more than twice as fast locally, which seems a lot considering jade in production mode should be rendering from an in memory cache. I'm using node 0.8 and the version 2.5.11 of express in production mode with the view cache option explicitly set to true . apache bench

jade template engine (under node.js): multi-line block without pipe symbol

别来无恙 提交于 2019-12-03 11:31:32
问题 I'm currently using Jade on a new project. It seems well-suited to composing webapp layouts, but not for writing static content, such as a web page of elements containing text. For example, to create such a paragraph, I believe I need to do this: p | This is my long, | multi-line | paragraph. For a static web page full of real paragraphs of text, using jade becomes a burden due to that pipe symbol at the beginning of each line. Is there some sort of syntactic sugar for marking the whole block