pug

Change the “No file chosen”:

爱⌒轻易说出口 提交于 2019-11-27 06:47:17
I have a button "Choose file" as follows (I am using Jade but it should be the same as Html5): input(type='file', name='videoFile') In the browser this shows a button with a text next to it "No file chosen". I would like to change the "No file chosen" text to something else, like "No video chosen" or "Choose a video please". I followed the first suggestions here: I don't want to see 'no file chosen' for a file input field But doing this did not change the text: input(type='file', name='videoFile', title = "Choose a video please") Can anybody help me figure out where the problem is? I'm pretty

How can I render inline JavaScript with Jade / Pug?

坚强是说给别人听的谎言 提交于 2019-11-27 04:58:41
问题 I'm trying to get JavaScript to render on my page using Jade (http://jade-lang.com/) My project is in NodeJS with Express, eveything is working correctly until I want to write some inline JavaScript in the head. Even taking the examples from the Jade docs I can't get it to work what am I missing? Jade template !!! 5 html(lang="en") head title "Test" script(type='text/javascript') if (10 == 10) { alert("working") } body Resulting rendered HTML in browser <!DOCTYPE html> <html lang="en"> <head>

Is there any way to use multiple view engines with Express + Node.js

十年热恋 提交于 2019-11-27 04:20:50
问题 Scenario : I had developed some transactional pages using Node.js, Express + Handlebars as view engine and MongoDB. Now the issue is during module integration I got some of the pages which are built on Express + Jade as view engine. Question : How to integrate pages built on Handlebars & some on Jade ? 回答1: Add both engines and consolidate.js in your package.json In yourapp.js var engines = require('consolidate'); app.engine('jade', engines.jade); app.engine('handlebars', engines.handlebars);

Rendering HTML in variable using Jade

∥☆過路亽.° 提交于 2019-11-27 04:19:51
问题 I have some text stored in a variable which contains some HTML. For example, the <b>cat</b> in the hat. However, when I render it in Jade, it shows up with the tags instead of rendering the formatting. How can I fix this? 回答1: Code buffered by = is escaped by default for security, however to output unescaped return values you may use != p!= aVarContainingHTML Pug Doc 回答2: The syntax you need is : !{yourJsVariable} if you use #{yourJsVariable} it shows < >, but with !{} it doesn't. 来源: https:/

Change value of input placeholder via model?

萝らか妹 提交于 2019-11-27 02:28:55
问题 I'm trying to change the value of the input placeholder from a controller but cant quite figure out how. input(type='text', ng-model='inputText', side='30', placeholder='enter username') Is there a way to modify a model's element attributes? 回答1: You can bind with a variable in the controller: <input type="text" ng-model="inputText" placeholder="{{somePlaceholder}}" /> In the controller: $scope.somePlaceholder = 'abc'; 回答2: The accepted answer still threw a Javascript error in IE for me (for

socket.io - can't get it to work, having 404's on some kind of polling call

你离开我真会死。 提交于 2019-11-27 01:28:56
问题 I'm trying to get a server set up with socket.io, with bad results. I am mostly following this guide, although it's somewhat out of date: http://www.williammora.com/2013/03/nodejs-tutorial-building-chatroom-with.html The problem comes with socket.io, I'm not sure if it's client or server side. It appears to be trying to continuously poll the server, but is getting 404's back. That sounds like socket.io isn't running, but it all looks okay to me. It may also have something to do with paths and

Jade template, how to pass concrete object to pages?

陌路散爱 提交于 2019-11-27 00:57:25
问题 I have a jade template for my node.js project. I would like to send an object to the jade template and pass it to a function inside the page (to render something). I am sure I send the right stuff from the server like this res.render(__dirname + '/pages/viz.jade', { vizJson: newJson, }); in the client I do something like this: script sunburst(#{vizJson}) Thus, inside a script function, I want to call a function that creates my visualization with some json I created on the server side. The

Using HTML in Express instead of Jade

我的梦境 提交于 2019-11-26 23:56:51
问题 How to I get rid of Jade while using Express with Node.JS? I want to just use plain html. In other articles I have seen that people recommended app.register() which is now deprecated in the latest version. 回答1: You can do it this way: Install ejs: npm install ejs Set your template engine in app.js as ejs // app.js app.engine('html', require('ejs').renderFile); app.set('view engine', 'html'); Now in your route file you can assign template variables // ./routes/index.js exports.index = function

What's the use of Jade or Handlebars when writing AngularJs apps

不打扰是莪最后的温柔 提交于 2019-11-26 23:49:11
问题 I am new(ish) to the whole javascript full stack applications, and completely new to Angular, so I was hoping somebody can put the record straight for me here. Why would I need to use a templating framework like Jade or Handlebars when writing client side apps using AngularJS. I should say that I have never used any of these templating frameworks either. So I am not familiar with the advantages completely. But when I look at Handlebars for example, it does many of the same things as I would

JADE + EXPRESS: Iterating over object in inline JS code (client-side)?

寵の児 提交于 2019-11-26 23:04:09
问题 i want to implement a google map based on its api. i want to add a path based on coordinates to it. therefore i get my coordinates from my model and want to iterate over the object to fille the map with this points. in my jade template i include the api js code like this: script(type='text/javascript') function initialize() { var myLatLng = new google.maps.LatLng(0, -180); var myOptions = { zoom: 3, center: myLatLng, mapTypeId: google.maps.MapTypeId.TERRAIN }; var map = new google.maps.Map