pug - 渲染哈巴狗扩展/块时遇到问题?
问题描述
块内容标题未显示在我的 html 页面上。我已经浏览了附近的一些教程和其他 stackoverflow 文章,因为我可以告诉我遵循正确的语法。我确定我错过了一些东西,但我找不到它。如果可以的话请帮忙。
我在代码中留下了评论。我尝试更改块的位置以及代码的缩进。我还尝试按照其他文章中的建议添加附加和前置。以及将标题更改为标题以确保我没有冲突。
doctype html
html
body
block header // have tried with append & prepend and tried it below h1 tag
h1 Index Page
p This is the index page
```header.pug:
extends index
block header
label page1
label page2
I am not getting an errors with this code. It is not displaying any of the content from header.pug.
解决方案
我认为您对扩展的工作方式感到困惑。包含extends
声明的文件就是页面,它只是使用它扩展的另一个文件中的标记。
我修改了@kmgt 的答案来说明这一原则。请注意每个文件的不同名称。
包装器.pug
doctype html
html
head
body
include header
block content
头文件.pug
label page1
label page2
指数.pug
extends wrapper
append content
h1 Index Page
p This is the index page
关于.pug
extends wrapper
append content
h1 About Page
p This is the about page
推荐阅读
- javascript - 我的两个选择标签在 php 循环 1 中用于产品重量,另一个是产品价格。我想要,每当单位改变时,价格就会自动改变
- php - Bash trap command failing to catch fatal php script exit code 255
- c++ - 为什么很多项目不提供预编译的二进制文件?
- c++ - 如何将 const 数组存储在可执行文件中?
- tradingview-api - Tradingview轻量级图表时间轴奇怪的行为
- mongodb - 如何在文档(MongoEngine 中的类)上指定排序规则?
- javascript - 创建一个链接以将事件添加到 yahoo calandar
- reactjs - React Jest 测试无法使用 ts-jest 运行 - 在导入的文件中遇到意外的令牌
- waze - 来自 Waze 的交通数据
- python - 如何通过 Pandas DataFrame 优化循环