pug

Integration of Mathjax and JadeJS

我只是一个虾纸丫 提交于 2019-12-08 09:01:24
问题 I have a problem integrating Mathjax and Jade in Express. I need to show formulas inside a 'pre', so I am trying to configure Mathjax through a script. This is my code: script(type="text/x-mathjax-config") MathJax.Hub.Config({ tex2jax: { inlineMath: [['$','$'], ['\\(','\\)']], skipTags: ["script","noscript","style","textarea","code"] } }); My problem is that when I try to see the page it throws this error: SyntaxError: Unexpected token { at Object.Function (unknown source) at Object.exports

ClientJade - Trouble executing jade.render()

浪尽此生 提交于 2019-12-08 07:02:36
问题 I've run into a problem in the clientside code for a Node.js app I'm working on. The idea behind this is to update the browser immediately as the socket receives an event. This is the script block on the client side: script(src='/scripts/jadeTemplate.js') script(src='/socket.io/socket.io.js') script(type='text/javascript') var socket = io.connect(); socket.on('obj', function(obj) { var newsItem = document.createElement("item"); jade.render(newsItem, 'objTemplate', { object: obj }); $('

Can I use Stylus and/or Jade with Spring 4 MVC project?

喜欢而已 提交于 2019-12-08 04:13:42
问题 I have gotten used to/fell in love with Stylus for preprocessing css and Jade for simplifying my HTML in the Node.JS world. Now I am back to working on a Spring 4 MVC project and would like to use those technologies in this environment. Is it possible to integrate them (I am using Gradle)? A quick google search for Stylus Java Gradle returned no helpful responses. Thanks! 回答1: Stylus and Jade seem to be popular in the JavaScript world, not so much in the JVM world. Here are the closest tools

How to ensure the javascript is at the bottom of the code in Jade template?

☆樱花仙子☆ 提交于 2019-12-08 04:13:41
问题 I'm new to Jade template. Here is the layout.jade: html head meta(charset='UTF-8') title MyApplication meta(content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no', name='viewport') link(href='/bootstrap/dist/css//bootstrap.min.css', rel='stylesheet', type='text/css') body block content script(src='http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js') script(src='/bootstrap/dist/js/bootstrap.min.js', type='text/javascript') As you see, there are two

How to ensure the javascript is at the bottom of the code in Jade template?

我是研究僧i 提交于 2019-12-08 03:17:26
I'm new to Jade template. Here is the layout.jade: html head meta(charset='UTF-8') title MyApplication meta(content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no', name='viewport') link(href='/bootstrap/dist/css//bootstrap.min.css', rel='stylesheet', type='text/css') body block content script(src='http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js') script(src='/bootstrap/dist/js/bootstrap.min.js', type='text/javascript') As you see, there are two javascript at the end of the template file. My another jade file, home.jade is: extends layout block content

jade the “filename” option is required to use “extends” with “relative” paths

允我心安 提交于 2019-12-08 03:14:57
问题 I have following folder structure (simplified): project - app.js - views - index.jade - layout.jade - public ... I want to generate an index.html file from index.jade and use the following command in my Terminal (Mac OS X): jade < index.jade > index.html However I receive an error saying: /usr/local/lib/node_modules/jade/lib/runtime.js:231 throw err; ^ Error: Jade:1 > 1| extends ./layout 2| 3| block mainContent 4| center the "filename" option is required to use "extends" with "relative" paths

sails can't find layout.jade

落花浮王杯 提交于 2019-12-08 02:06:50
问题 I am starting to learn Sails (0.9.7, node 0.10.16) and running through the sailscasts episodes. I am also trying to use jade as I do so. Where I am stuck now is that sails is not finding views/layout.jade. I backed out all the jade stuff and redid with ejs and sails is not finding views/layout.ejs. As a last resort, I cloned activtyoverlord (the sailscasts app) and when I sails lift activityoverlord does not find its views/layout.ejs. Any suggests as to what I might be doing wrong? 回答1: I'm

Jade URL Routing in Node Express

谁说胖子不能爱 提交于 2019-12-08 01:56:38
问题 I am building a Node Express application using Jade, and I am confused about how to route my views to the specific requests the browser will make. I understand that in order to get URLs to work in the browser, we need to use Node's routes; however, from looking online, I have discovered that Express has its own router. I used PHPStorm to start up my project, and the index.jade will load... but how do I load the others? Here is my existing code: var express = require('express'), routes =

How do I send on object from MongoDB to jade?

爷,独闯天下 提交于 2019-12-08 01:36:28
问题 I'm trying to access an object that I retrieve from MongoDB with my client-side JS. Specifically, I want to be able to loop through and use the arrays within the object. Here is my server-side JS which successfully finds the results and logs them to terminal. app.get("/post/:id", function (req, res, next) { var id = req.param('id'); var query = BlogPost.findById(id).populate('author'); BlogPost.find(query, {"answers":"true", "blanks":"true", "_id":0}, function(err, results){ console.log(

Conditional Include in Jade + Express

可紊 提交于 2019-12-07 23:01:48
问题 How can one use if -else statement on "include" in jade?? For example, if I have two separate navigation bar templates navbar.jade and navbar_notloggedin.jade I would like to do: input(type='hidden', value= user.user)#username - if(user.user!="") include navbar - else if(user.user=="") include navbar_notloggedin 回答1: You can use, -if (user.user) include navbar -else include navbar_notloggedin The if statement will check whether the variable is defined or not, not whether it is an empty string