pug

how to escape <> in javascript underscore template?

十年热恋 提交于 2019-12-13 06:03:20
问题 when using underscore template i want to interpolate a value in anchor's href attribute like a(href= "<%= id %>", class='products') //underscore template in jade but the out put is <a href="&lt;% id %&gt;" class="products"> so how to escape the < and > sign , and interpolate the value correctly? 回答1: Use != instead of = to unescape. In your case: a.products(href!="<%= id %>") 来源: https://stackoverflow.com/questions/12351148/my-underscore-template-is-not-working-in-jade

Why doesn't my external jQuery click() event work in Jade?

[亡魂溺海] 提交于 2019-12-13 06:01:38
问题 For some reason I can't get this click event to work when clicking any element, although it does work when I click the body. I know the ID is correctly assigned because the CSS also works fine. Here's the JS: $('h2').click(function() { alert( "h2 clicked." ); });//DOES NOT WORK $('#whatever').click(function() { alert( "Whatever clicked." ); });//DOES NOT WORK /* $('body').click(function() { alert( "Body clicked." ); }); */ //THIS WORKS WHEN UNCOMMENTED console.log('thank you!'); //THIS WORKS

how to toggle using multiple buttons and pass info to the output JQuery

泪湿孤枕 提交于 2019-12-13 05:26:27
问题 JQUERY CODE: $('#selector button').click(function() { $(this).addClass('active').siblings().removeClass('active'); $('#gaga').toggle }) PUG CODE FOR #gaga element: p#gaga | This is `${Value}` PUG CODE FOR #gaga element: How can I use three buttons to toggle the #gaga element on when button is active and off when you click outside the specific button and pass a different Value for ${Value} depending on the clicked button. Plus have only one instance of #gaga element running at a time. Meaning

How can I use the “locals” option in jade compile(), client-side?

浪子不回头ぞ 提交于 2019-12-13 04:46:58
问题 What I'm trying to achieve Server is a Node.js application. I'd like to share code with the client as Jade template helpers (for functions) or globals (for objects/variables) . New helpers and globals should be available in every client template. This question is NOT about adding helpers to Jade when jade is used server-side. The code I wrote a RequireJS wrapper for Jade compile() function, passing the locals object (filled with properties to share) inside options : // ./wrappers/jade.js

CSS doesn't work with jade

牧云@^-^@ 提交于 2019-12-13 04:33:26
问题 I've set up an app with node.js and jade. This is my view: html head title My test page link(rel='stylehseet', link='/css/main.css') body h1 My Jade template p= message a(href='/about') About The problem is the link tag. It doesn't load the css. It works if I change it to <link rel="stylesheet href="/css/main.css" /> (swapping out the jade for regular css). This is how I serve and route index.html : app.use(express.static(__dirname)); app.get('/', function(req, res) { res.locals.message =

ul in li , tree display with jade

瘦欲@ 提交于 2019-12-12 23:53:10
问题 I have a object of object of object ... i have a tree ! i use this jade code for display my tree : mixin file_list(files) ul each file, i in files li #{file.id} if file.children.length > 0 mixin file_list(file.children) but the result is: <ul> <li></li> <ul> <li></li> </ul> </ul> i need : <ul> <li> <ul> <li></li> </ul> </li> </ul> 回答1: mixin file_list(files) ul each file, i in files li #{file.id} if file.children.length > 0 mixin file_list(file.children) 来源: https://stackoverflow.com

Jade parse error

醉酒当歌 提交于 2019-12-12 23:08:15
问题 Update: I just found that I installed the latest code for node. I just re-installed last stable version and it seems to work fine for me. JUST FYI - The node version I was using - Mac-mini:helloworld nimahajan$ npm -v 1.3.11 Mac-mini:helloworld nimahajan$ node -v v0.11.8-pre ========================================================= I am trying to create a simple hello world example. After npm install and node app.js, I always get below error and can't seem to get around this .. jade@0.35.0

Using global config variable in express — Node js framework

帅比萌擦擦* 提交于 2019-12-12 22:30:40
问题 I am working with amazon aws server and writing an application to access my instances. But I am not able to pass around the amazon global config variable to the javascript file that gets executed when the button is clicked. This is my structure -- app.js -. var express = require('express') , http = require('http') , us = require('underscore') , aws = require('aws-sdk') , fs = require('fs'); .... var contents = fs.readFileSync("aws_config/LAUNCH.config.json"); var launch_config = JSON.parse

Express throwing unexpected token “indent”

♀尐吖头ヾ 提交于 2019-12-12 19:04:57
问题 I'm trying to deliver a static html file which uses jquery and other libraries and i want to know how to do his with express. Here's my app.js code ( express server file ) var express = require('express') , routes = require('./routes') var app = module.exports = express.createServer(); app.configure(function(){ app.set('views', __dirname + '/views'); app.use(express.static(__dirname + '/public')); }); app.configure('development', function(){ app.use(express.errorHandler({ dumpExceptions: true

Sending empty {} after form “post” with pug in node.js

蹲街弑〆低调 提交于 2019-12-12 13:35:30
问题 I'm trying to pass form data from login page to signin page via post using fetch with this pug code: form(id="form-login") input(type="text", name="email", value="", placeholder="Tu email") br input(type="password", name="password", value="", placeholder="Tu contraseña") br input(type="submit" value="Conectar") script. const formLogin = document.querySelector('#form-login'); const formData = new FormData(formLogin); formLogin.addEventListener('submit', function(event) { console.log('Form Data