pug

Create variables inside an each loop in a pug template

一笑奈何 提交于 2019-12-24 19:27:11
问题 How can I create variables inside a loop in pug and call them later? I passed a variable words from an express js server to a pug template and I looped through the variable: each word, index in words - var spelling = #{word['orth']}; - var pronunciation = #{word['pron']}; Then I tried to call the variables: ul #{spelling} I have this error: SyntaxError: Unexpected character '#' 回答1: Remove all these unnecessary characters when access word inside the each loop. each word, index in words - var

Node.JS ExpressJS async vs sync

混江龙づ霸主 提交于 2019-12-24 12:50:14
问题 Good morning stackoverflow I have this route: app.get('/myaccount', messages.getMessages, function(req, res, next) { messages = ''; res.render('myaccount', { messages: messages }); }); the messages.getMessages does a bunch of stuff by calling out to another server via superagent and getting some messages to bring back to the user (in that messages variable) The problem here is that sometimes... messages.getMessages might take 2-3 seconds to retrieve all the messages so when I refresh the page

No directive with “exportAs” set to “ngModel” angular 6

旧巷老猫 提交于 2019-12-24 10:46:07
问题 I'm trying to validate a form with angular 6. Here's my PUG code:- .form-group input.input-lg.form-control(type="text", placeholder="Your firstname", name="fname", #fname="ngModel", required) .alert.alert-danger(*ngIf="fname.invalid") p([hidden]="!fname.errors.required") First name is required` and I get this error: Uncaught Error: Template parse errors: There is no directive with "exportAs" set to "ngModel" (" ]#fname="ngModel" required="required"/> I've already imported the FormsModule in

express + stylus + jade, nothing gets compiled

痴心易碎 提交于 2019-12-24 03:16:08
问题 I cannot get this simple app.js to work: static files are served but jade and styl files are not compiled. Here the __dirname ls: damianomacbook:www damiano$ ls app.jade app.js app.styl config.xml johnd.jpg .jade and .styl files are served normally and plain. Here what happens when curling css and html files (which the middlewares functions are supposed to generate on the fly): damianomacbook:www damiano$ curl localhost:8080/app.css curl: (52) Empty reply from server damianomacbook:www

loadHtml instead of loadUrl in atom-shell? (trying to use jade)

落爺英雄遲暮 提交于 2019-12-24 02:44:35
问题 atom-shell only has a method to load HTML from a URL window.loadUrl('file://...') But I want to use Jade var html = jade.renderFile('file://...'); Is there a way to use the compiled html in atom-shell window ? Something like loadHtml(html) ? I suppose I could run an express server that serves compiled html but that would be rather inefficient.. 回答1: In case of a mac: /usr/bin/open -a "/Applications/Google Chrome.app" --args 'data:text/html,<html><body><h1>title</h1><p>text</p></body></html>'

How to include a static JSON file for compilation with Jade and Grunt

坚强是说给别人听的谎言 提交于 2019-12-24 02:01:50
问题 how do I compile Jade templates to static HTML via Grunt where my data is already held in a JSON file? Say I have this Gruntfile.js module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-jade'); grunt.initConfig( { jade: { html: { src: './*.jade', dest: './index2.html', options: { client: false, pretty: true } } } }); grunt.registerTask('default', 'jade'); }; This JSON file (./data.json) { "foo": {value: 1}, "bar": {value: 2}, "baz": {value: 3} } And this Jade (./index.jade) ul

While using Bootstrap-Vue, how do you prevent a b-dropdown from closing when clicking on a nested b-input component?

烈酒焚心 提交于 2019-12-24 01:37:42
问题 I'm pretty sure I just don't understand how to implement Vue's Event Modifiers. According to that documentation, all I have to do is add this: <!-- the click event's propagation will be stopped --> <a v-on:click.stop="doThis"></a> Here's how I interpreted the example into my pug code: b-dropdown(text="Actions") b-dropdown-item b-form(inline) .row .col b-input(@click.stop='' placeholder="#123") b-button(:href='printCheck' variant="primary") Print Check It looks pretty simple, however it's not

Pulling from specific subfolders using {% for post in site.posts %}

我们两清 提交于 2019-12-24 01:18:43
问题 I'm currently working on my first Jekyll site. I have a page in which 2 seperate sections display previews of certain posts (a styled thumbnail). What I want is for these sections to display posts from different subfolders in _site/_posts. I have organized _posts to contain two subfolders, /lesplannen and /verslagen (lesson plans and reports), each containing a bunch of articles. My code for one of these sections is as follows (Jade formatting): {% for post in site.posts limit: 4 %} a(href="{

Span within a sentence with jade

廉价感情. 提交于 2019-12-24 01:16:18
问题 How would I be able to do this with Jade? <h3 class = "blurb"> how would I <span>do this</span></h3> I can do pretty much everything but introducing a span mid sentence. 回答1: this should help you: h3 how should I span do this Your output code will not be exactly what you want, but when it's rendered in html, it should be what you need 回答2: h3.blur. how would I <span>do this</span> OR h3.blur | how would I span do this Please note that copying above snippet may not work because of the

OnsenUI loads page in text, via a splitter

可紊 提交于 2019-12-24 00:53:06
问题 I have previously created a web app, and now I would like to integrate it with OnsenUI to enable my app to be used on all mobile devices as well as the web. I am using a splitter in a toolbar which will be the header of all pages, and it will redirect the user to other pages when they click an item in it. Clicking the home item successfully redirects to the home page (index, which is already loaded correctly). However, clicking any of the other items in the splitter redirects me to the