pug

Output a server generated json object in jade without json parse

╄→гoц情女王★ 提交于 2019-12-09 15:42:20
问题 I have a JSON object that does not conform to JSON standards, and I cannot change the structure of the object to make it adhere to JSON standards. I need to make this object render in the middle of a javascript block in a Jade template. The object is actually a configuration object that is going in a function block in the template. Here is the object. { services: [], version: "1438276796258", country: "default", role: "User", Zack_Init: function () { }, Zack_Global: function (event) { }, Zack

get user agent from inside jade

旧巷老猫 提交于 2019-12-09 03:01:33
问题 I am trying to port a script I wrote for groovy over to jade, and have run into a stumbling block I need to access the user-agent from inside a jade file. Here is what I have tried so far: - var agent = req.headers['user-agent']; - var agent = headers['user-agent']; - var agent = navigator.userAgent; every time I get a 500 error from express. Is this even possible? I know I could do it in a module and pass it to the render statement, but that would mean passing it to EVERY render, as it needs

AngularJs: Directive NEVER called

拥有回忆 提交于 2019-12-08 19:12:16
问题 I have a directive that spontaneously stopped working. For some reason, it is never called with no error prints out in the console. This is odd because other directives (which seem virtually identical) are working (see the very end of the post for a working directive). This is the directive : angular.module('popup').directive('popup', ['Locator', 'PopupService', // This line of code is reached function(Locator, PopupService) { return { restrict: 'A', scope: { "show": '=', "anchor": '=',

How to add br tag with Jade HTML

拥有回忆 提交于 2019-12-08 18:31:12
问题 I need add br tag but this not working. table tbody td Juan Perez td 01 33 4455 6677 td Av José Vasconcelos 804-A Pte. br Col. Los Sabinos,CP. 66220, San Pedro, N.L. 回答1: Put the text on a new line with a preceding | : table tbody tr td Juan Perez td 01 33 4455 6677 td Av José Vasconcelos 804-A Pte. br | Col. Los Sabinos,CP. 66220, San Pedro, N.L. You could also place both text nodes on new lines to improve readability as well: table tbody tr td Juan Perez td 01 33 4455 6677 td | Av José

Controller is loaded in DOM but the view not loaded and can't find controller- oclazyload with jade(pugjs)

跟風遠走 提交于 2019-12-08 17:17:21
问题 I am using angular 1.6 for my project and angular-ui-routing for routing with PugJs for HTML templates. I am trying to implement Lazyload in my application, but somehow its not working may be due to jade. code : var app = angular.module('myApp',['ui.router','oc.lazyLoad']); app.config(['$ocLazyLoadProvider', function($ocLazyLoadProvider { $ocLazyLoadProvider.config({ debug: true, modules: [{ name: 'js', files: ['js/*'] }] }); }]); .state("exampleState", { url: '/example', templateUrl: '

How do I get the filename of the executing jade script

余生颓废 提交于 2019-12-08 16:29:21
问题 Is there a global object that is accessible from within a jade template with various parameters? Is there a global variable with the path of the currently executing jade file? !!! 5 html head title Test body //- I want to be able to know what the current script file is... p Hello, I am: #{globals.scriptfilename} 回答1: If you're using gulp-jade , add gulp-data to the mix and use this code: var jade = require('gulp-jade'); var data = require('gulp-data'); gulp.src('**/*.jade') .pipe(data

requirejs - not loading certainly with proper path given

主宰稳场 提交于 2019-12-08 14:28:06
问题 I am using 'requirejs' for my app development, it was worked properly but certainly it is not working now. all the path are correct. but i am getting error on load the page error i am getting: Remote Address:127.0.0.1:3000 Request URL:http://localhost:3000/js/lib/require.js //but exactly the file is here. Request Method:GET Status Code:404 Not Found here is my html for jade: doctype html html(lang='en') head title= name link(rel='stylesheet', href='styles/bootstrap.min.css') link(rel=

Grunt conditional option

社会主义新天地 提交于 2019-12-08 11:50:13
问题 I'm attempting to create a Jade task that will have a build and dev task that have very similar options, except a dev boolean, and a different destination. The simplest way I've been able to achieve this is: jade: { dev: { options: { data: { dev: true, // dev true config: ..., pkg: ..., helpers: ... } }, files: [{ dest: '<%= config.workingDir %>', ... }] }, build: { options: { data: { // no dev config: ..., pkg: ..., helpers: ... } }, files: [{ dest: '<%= config.buildDir %>', ... }] } } There

passing data between server and client (node.js + mongodb)

只愿长相守 提交于 2019-12-08 11:45:11
问题 I'm working with node.js express and mongodb, I have a input data from client, I need to pass the data to server look for its property and send to the client in another page. Now I have problem with req.body.age that suppossed to get the data from client's input and use find() to get its appropriate property. Server side code: functions are routed in another .js file exports.find_user = function(req, res) { res.render('find_user.jade'); }; exports.user = function(req, res){ member = new

Warning: Unexpected block “content”

試著忘記壹切 提交于 2019-12-08 11:28:05
问题 Even though I've got the blocks correctly addressed they aren't being brought into the layout page: //- layout.jade doctype html html head title My Page body block content //- Main content goes here //- index.jade extends ./layout.jade block title title Article Title block content h1 My Article I've since found the answer and think it should be documented to help others... 回答1: You will get that error if you have a comment //- on the same line as the block in your layout.jade. 来源: https:/