pug

Jade Mixins in AngularJS

对着背影说爱祢 提交于 2020-01-14 13:03:42
问题 Hi I would like to implement Jade templates in my AngularJS project, and have mixin in my template (reusable code). However the problem that I am facing is that we cannot use Mixin with arguments. Am I doing it correctly or is there any alternative for the same in AngularJS that I am missing? 回答1: You can create an js object from your model and pass it as strings to the mixin like the following: +avatarRow({name: '{{avatar.name}}', uuid: '{{avatar.uuid}}', verificationCode: '{{avatar

How to do nested iterations in jade?

巧了我就是萌 提交于 2020-01-14 05:36:09
问题 ul li a(href='') menu1 li a(href='') menu2 ul li a(href='') sub-menu2 li a(href='') menu3 ul li a(href='') sub-menu3 ul li a(href='') secondary-submenu3 This is what I'm trying to achieve, instead of writing the above jade code I want to be able to generate it using loops. I tried the jade documentation, the examples show only one level of loop. For eg. I could try this -var menus = [ 'menu1', 'menu2', 'menu3' ]; ul each menu in menus li a(href='') #{menu} But this is not enough. if I try

Jade - calling page specific css pages

元气小坏坏 提交于 2020-01-14 05:34:10
问题 I have page specific css files I would like to call automatically. Does anyone have a nice way of doing this elegantly? 回答1: This should do it link(rel="stylesheet", href="#{req.path + '.css'}", type="text/css") Where you pass either req (the request object) as a local variable when rendering the jade template (or even just pass in req.path as path ). This could just be handled in your layout.jade and it will work for each of your route paths. If you want to get fancy, you could establish a

Google maps error during visualization

陌路散爱 提交于 2020-01-14 05:00:08
问题 I have a small directive that handle google map in my Angular application: app.directive('googleMaps', function($rootScope, $q, $window){ var mapLoader = $q.defer(); function loadGoogleApi(key){ var script = document.createElement('script'); script.type = 'text/javascript'; script.src= "https://maps.googleapis.com/maps/api/js?key=" + key + "&callback=initMap"; $('body').append(script); return mapLoader.promise; }; $window.initMap = function(){ mapLoader.resolve(); }; return { restrinct: 'E',

Node.js JADE linebreaks in source?

一笑奈何 提交于 2020-01-13 10:23:06
问题 I wonder, why i don't see any linebreaks in my sourcecode if i parse my jade template. It looks like this: !!! 5 html head title= title link(rel='stylesheet', href='/stylesheets/css.css') link(rel='stylesheet', href='/stylesheets/blitzer/jquery-ui-1.8.10.custom.css') link(rel='stylesheet', href='/stylesheets/table_jui.css') script(type="text/javascript", src="/javascripts/jquery.min.js") script(type="text/javascript", src="/javascripts/jquery-ui.min.js") script(type="text/javascript", src="

Res.Render is not a function error in node.js

▼魔方 西西 提交于 2020-01-13 06:39:51
问题 I am getting an "res.render is not a function error" in the Windows 10 Command Prompt when I try to run my node.js code. What is causing this error and how can I get rid of it? Here is my .js file: /*eslint-env node*/ //------------------------------------------------------------------------------ // node.js starter application for Bluemix //------------------------------------------------------------------------------ // HTTP request - duas alternativas var http = require('http'); var

Link to static files from Jade template rendered from a sub route

南笙酒味 提交于 2020-01-11 10:54:25
问题 I have a very basic problem with Node.js/Express/Jade that's surprisingly hard to describe. In my node.js application I use the Express framework for routing of HTTP requests. I also use Jade templates as views, who themselves link to files (css, js etc.) inside a directory that I have declared as static through the app.use(express.static(__dirname + '/public')); command. When I route requests to resources like /about or /contact everything works as expected. But I found that as soon as my

How can a Jade template use client-side global variables?

≯℡__Kan透↙ 提交于 2020-01-11 05:07:06
问题 Lets say I have a browser open, and in JavaScript I declare a global variable. window.myGlobalVar = 'Hello!'; I then compile a jade template for client side rendering that uses that variable. .foo= myGobalVar Which I compile like so: jade.compile('.foo= myGobalVar', { client: true, compileDebug: false }).toString() Which yields this template function: function anonymous(locals) { var buf = []; var locals_ = (locals || {}), myGobalVar = locals_.myGobalVar; jade.indent = []; buf.push("\n<div

Jade, how to escape hash character?

删除回忆录丶 提交于 2020-01-06 15:51:16
问题 I have the following line in my Jade template: img(src='#{similarArtist.image[0].#text}') Do not ask me why Last.fm guys decided it was a good idea to use a name starting with hash in JSON document, but this is what I am dealing with. It seems the 2nd hash sign trips up Jade. Maybe it expects two braces afterwards? I have tried prepending it with a backslash character (traditionally an escape operator) but that did not help. So what can I do in this case? I really need to access that #text

Jade, how to escape hash character?

为君一笑 提交于 2020-01-06 15:51:06
问题 I have the following line in my Jade template: img(src='#{similarArtist.image[0].#text}') Do not ask me why Last.fm guys decided it was a good idea to use a name starting with hash in JSON document, but this is what I am dealing with. It seems the 2nd hash sign trips up Jade. Maybe it expects two braces afterwards? I have tried prepending it with a backslash character (traditionally an escape operator) but that did not help. So what can I do in this case? I really need to access that #text