Tag: pug pugjs

在帕格/翡翠dynamic包括解决方法

据我所知,帕格不支持在模板中dynamic包含或扩展。 即 extend path/to/template 工作但不是 extend #{dynamic_path_to_template} 有没有一个解决方法(无论是复杂的),将允许相同的目标,在运行时修改视图使用的模板 上下文 :我的用例是我正在开发一个npm模块,用于扩展其他视图的模板位于模块内部。 在模块发布和安装之后,path将被定义(即node_modules / my_module / path / to / template),但是在开发阶段,我只需要能够“npm link”到模块并拥有模板工作。 我也不想硬编码的链接,所以我可以发布相同的代码作为testing。

使用Pug模板时意外的令牌“缩进”

我有一个简单的应用程序,应该输出一个小内容。 我使用NodeJs,Express和帕格 。 const pug = require('pug'); const express = require('express'); const app = express(); const indexFile = 'index'; // the file to load app.set('view engine', 'pug'); // use pug app.get('/', function (req, res) { res.render(indexFile, {content: 7}); // load the file and set the variable to 7 }); app.listen(8888, function () { console.log('Server running […]

Node.js,Jade / Pug,如何提供全部和部分模板?

如果通过ajax发出请求,我想只发送来自page1.jade的块内容,如果是正常的GET,它应该回答这个内置到layout.jade中的块

我如何在翡翠(哈巴狗)做到这一点?

<ul class="dropdown-menu"> <li> <a href="javascript:void(0)"> <i class="ti-user mr-5"/> Profile </a> </li> </ul> 我不知道如何把i和“ 个人资料 ”放在a 。 请帮帮我!

包括帕格文件导致错误,但翡翠工作正常

在这里遇到一个奇怪的问题。 我有一个很基本的玉/帕格包括去这里: extends base.pug block vars – var title = 'Home' block body header include ./includes/header.pug 一个简单的说明,只是使用扩展基地(没有扩展名)是行不通的。 但是这包括以下错误: TypeError: Cannot read property 'replace' of undefined at before (/var/node/website/node_modules/pug-linker/index.js:104:48) at walkAST (/var/node/website/node_modules/pug-walk/index.js:13:26) at /var/node/website/node_modules/pug-walk/index.js:21:16 at Array.map (native) at walkAST (/var/node/website/node_modules/pug-walk/index.js:20:29) at walkAST (/var/node/website/node_modules/pug-walk/index.js:33:21) at /var/node/website/node_modules/pug-walk/index.js:21:16 at Array.map (native) at walkAST (/var/node/website/node_modules/pug-walk/index.js:20:29) at /var/node/website/node_modules/pug-walk/index.js:21:16 at Array.map (native) […]

帕格(以前的玉)variables不能正常工作(插值)锚内部Href

我正在玩Node和Express,我正在使用Pug(以前的Jade)模板引擎来呈现我的html。 一切工作正常,直到我开始尝试将variables注入我的锚链接的href 。 奇怪的是,如果我改变我的快速应用程序view engine jade然后事情开始按预期工作。 根据我读过的其他文章,这个问题似乎是一个插值问题,但我似乎无法find一个资源或文档,显示如何正确解决这个问题。 防爆。 我从一个rooms json数组拉动数据,然后使用for循环遍历每个数组元素并输出每个房间的数据。 使用jade以下的作品。 table.table.table-striped thead tr th Name th Id tbody each room in rooms tr td(style="width: 50px;") a(href!="/admin/rooms/delete/#{room.id}") Delete td #{allTitleCase(room.name)} td #{room.id} 使用pug上述不能正常工作。 特别是a(href='/admin/rooms/delete/#{room.id}') Delete链接无法正常工作。 而不是注入房间id到链接href,它实际上输出#{room.id}作为href链接的结束部分。 任何想法如何解决这个pug ? 请注意,我已经尝试了所有以下使用pug但这些选项都没有工作。 a(href="/admin/rooms/delete/#{room.id}") Delete a(href!="/admin/rooms/delete/#{room.id}") Delete

pugjs(玉)模板引擎加载css文件

我一直在GitHub的例子中search,但我找不到如何加载一个简单的CSS文件到我的布局。 我的第一个想法是做这样的link(href="my.css")但它似乎根本不工作。 该href指向一个正确的位置在线(检查和工作),也许我忘记了一些东西?