pugjs

Pug dynamic image src interpolation

萝らか妹 提交于 2021-02-08 19:29:05
问题 I have stored a dynamic url link into a pug variable #{img}. Now I want to include that variable into my image element. Can anyone help me fill in the blank? #{img} //some dynamic url img(src=" ") //want to set src = #{img} 回答1: do it like this - var img = "img/test.jpg" img(src=img) and read this 来源: https://stackoverflow.com/questions/47483937/pug-dynamic-image-src-interpolation

Pug dynamic image src interpolation

喜你入骨 提交于 2021-02-08 19:24:37
问题 I have stored a dynamic url link into a pug variable #{img}. Now I want to include that variable into my image element. Can anyone help me fill in the blank? #{img} //some dynamic url img(src=" ") //want to set src = #{img} 回答1: do it like this - var img = "img/test.jpg" img(src=img) and read this 来源: https://stackoverflow.com/questions/47483937/pug-dynamic-image-src-interpolation

pugjs(jade) template engine loading css file

一曲冷凌霜 提交于 2019-12-20 09:28:02
问题 I've been searching in the examples on the GitHub but I couldn't find how to load a simple css file into my layout. My first thought was doing something like this link(href="my.css") but it seems it's not working at all. The href points to a correct location online (checked and working) thus maybe I'm forgetting something? 回答1: try: link(rel='stylesheet', href='/stylesheets/style.css') 回答2: I think you need to include the relationship. Try link(rel='stylesheet', href='my.css') 回答3: You need

How to get a Hexo-built site variables in a pug template?

扶醉桌前 提交于 2019-12-11 16:15:51
问题 I have a Pug template (for what will become the root index.html ) which is supposed to just list the titles of my posts: p first line of the page ul each post in site.posts li= post.title p last line of the page When building the site I get in index.html <p>first line of the page</p> <ul> <li></li> <li></li> </ul> <p>last line of the page</p> I have two posts on this site and the two <li></li> suggest that I iterate over the right variable (and that the variable is known). How can I get the

Workaround to dynamic includes in Pug/Jade

别等时光非礼了梦想. 提交于 2019-12-11 04:26:49
问题 I understand that Pug does not support dynamic includes or extends in templates. Ie extend path/to/template works but not extend #{dynamic_path_to_template} Is there a workaround (however convoluted) that will allow the same goal of modifying the template used by a view at runtime Context : My use case is that I am developing an npm module and the template being used to extend other views is located inside the module. After the module is published and installed, the path will be defined (ie.

jade/pug Is it possible to use variables on include statement?

扶醉桌前 提交于 2019-12-11 03:17:01
问题 I'm developing nodejs application and I have issue with include statement. It works when I use it like this: include ../mixins/root.pug ...but is it possible to use variables on include? None of these work: include #{process.env.MIXINS_PATH}/root.pug include !{process.env.MIXINS_PATH}/root.pug include `${process.env.MIXINS_PATH}/root.pug` Result is this: Error: ENOENT: no such file or directory 回答1: Dynamic includes are not supported: We don't support "Dynamic Include". There are lots of

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:/