pug

Jade - Controlling line-breaks in the HTML output

大城市里の小女人 提交于 2019-12-05 03:19:11
I have a simple search form I wish to implement using Jade. form input( type="text" size="16" placeholder="Enter your keywords") input( type="button" value="Search") The output is rendered as: <form> <input type="text" size="16" placeholder="Enter your keywords"> <input type="button" value="Search"> </form> This is perfect except that the line-break is causing a space between my button and the search button. I need no space between the textbox and the button. I need the code to render like this: <form> <input type="text" size="16" placeholder="Enter your keywords"><input type="button" value=

Toggle active link Bootstrap navbar

别来无恙 提交于 2019-12-05 02:38:25
问题 I've read a lot of posts on the subject, found almost always the same solution but it does not work for me... My problem is as follows : I want to use Twitter Bootstrap 2.3.2 and its navbar, so I include the css and js files. Just before that, I also include jquery. I then take an example given on the bootstrap site which display very well. However, I now want to set the menu item clicked as active and remove the active class from all others. I saw in the bootstrap.js file that this function

Using different indentation for Jade

断了今生、忘了曾经 提交于 2019-12-05 02:19:11
From this tutorial it seems that Jade requires 2-spaces tabs. Can I use another tabbing syntax with Jade? Ali Raza It's not necessary to use only two spaces for tabbing. You can use any number of spaces (consistently) or a tab character to indent. The only quirk is you can't use both spaces and tabs at the same time, or it will give an error while compiling. See this link Jade . user2803416 The tab size must be 4, when I use gulp-template. 来源: https://stackoverflow.com/questions/8378471/using-different-indentation-for-jade

Hogan JS IF statements

吃可爱长大的小学妹 提交于 2019-12-05 02:09:35
I don't really like the jade syntax and was wondering if I could do this simple comparison using hoganJS instead? The example code is written in JADE. I did some googling and there seems to be mixed opinion.. I just want to know if there is a way or will I need to change something? if user li a(href='/dashboard') Dashbaord li a(href='/logout') Logout else li a(href='/login') Logi§n block body Hogan is an implementation of Mustache so the same syntax applies. {{#user}} <li><a href="/dashboard">Dashboard</a></li> <li><a href="/logout">Logout</a></li> {{/user}} {{^user}} <li><a href="/login"

Jade: element attributes without value

感情迁移 提交于 2019-12-05 01:32:15
I am new to using Jade -- and it's awesome so far. But one thing that I need to happen is an element with 'itemscope' property: <header itemscope itemtype="http://schema.org/WPHeader"> My Jade notation is: header(itemscope, itemtype='http://schema.org/WPHeader') But result is: <header itemscope="itemscope" itemtype="http://schema.org/WPHeader"> How can I make sure that I get the right result -- itemscope instead of itemscope="itemscope" ? I just tried it in a Express.js/Jade project and the result i get is: <header itemscope itemtype="http://schema.org/WPHeader"></header> I also tried it in

Express, Jade, & NodeJS: Navigate between pages

我只是一个虾纸丫 提交于 2019-12-05 00:22:30
问题 How do I create a Jade page that has two buttons where each one of them redirects to another page made with Jade? 回答1: 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' }

Jade: declare a variable over multiple lines

我只是一个虾纸丫 提交于 2019-12-05 00:16:50
I have a jade variable declared like this: BUTTONS = { more_blue: {caption: BUTTONS_CAPTIONS.more, style: BUTTONS_STYLES.blue}, more_red: {caption: BUTTONS_CAPTIONS.more, style: BUTTONS_STYLES.red}, see: {caption: BUTTONS_CAPTIONS.see, style: BUTTON_STYLE_PHOTOS}, see_photos: {caption: BUTTONS_CAPTIONS.see_photos, style: BUTTON_STYLE_PHOTOS}, program : {caption: BUTTONS_CAPTIONS.program, style: BUTTON_STYLE_PROGRAM}, see_program : {caption: BUTTONS_CAPTIONS.see_program, style: BUTTON_STYLE_PROGRAM} } but I would like it to be more readable like this: BUTTONS = { more_blue: {caption: BUTTONS

Long block of text in Jade textarea?

给你一囗甜甜゛ 提交于 2019-12-05 00:09:29
I'm using Jade in my latest node.js app. I'd like to have a long block of text in a textarea by default. If I do something like this: textarea(id="theTextarea") it renders just fine: <textarea id="theTextarea"></textarea> However, if I do something like so: textarea(id="theTextarea") Hello world. I get this: <textarea id="theTextarea"> <hello>world</hello> </textarea> But I'd like it to be like so: <textarea id="theTextarea"> hello, world </textarea> Any ideas? textarea(id="theTextarea") | Hello | world. | Hello | moon. | Hello | sun. The | worked great for me. In my case though, I needed to

How do you set jade basedir option in an express app? (the “basedir” option is required to use “extends” with “absolute” paths)

孤街浪徒 提交于 2019-12-04 22:59:17
Going through the peepcode nodejs video and recreating the app on the current express/node versions I've ran into a small issue. file structure site - apps - - authentication - - - views - - - - login.jade - - - routes.js - node_modules - public - - images - - javascripts - - stylesheets - routes - views app.js login.jade: extends /views/layout block content form(action='/sessions', method='post') label | Username input(type='text', name='user') label | Password input(type='password', name='password') input(type='submit', name='submit') app.js var express = require('express') , user = require(

Update part of a page in jade?

谁说胖子不能爱 提交于 2019-12-04 22:01:52
I'm trying to make a search and send back the result to the same site, I've got the search to work but I can't get the result to be sent back. I want the start site to render the information without page reload. How can I send the search result back to the index.jade page without having to update it? function pagelist(items, res) { var document=''; var db = db_login; if ( items != null){ items.forEach(function(item) { document += '<a href=share/'+item._id+' class="searchElement">' document += item.document document += '</div>' }) if(document != ''){ res.send(document); }else{ } } } index.jade