Skip to content

Commit

Permalink
docs(html): template languages
Browse files Browse the repository at this point in the history
  • Loading branch information
guoyunhe committed Jan 5, 2025
1 parent 3860223 commit 215fece
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
23 changes: 22 additions & 1 deletion docs/coding/html.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,11 +510,32 @@ To fit iPhone's notch screen, you may need some extra configuration. [Learn more

了解更多 HTML 可访问性的知识,可以阅读[这篇 MDN 的文章](https://developer.mozilla.org/zh-CN/docs/learn/Accessibility)

## Template languages

There are many template languages to generate HTML files, e.g. [Nunjucks], [EJS]. Writting template language syntax should also follow some common specification.

This part uses [Nunjucks] as an example. But it should fit other template languages, too.

### Variables, filters and keywords MUST have spaces around

Level: **Mandatory**

```jinja
{# ❌ bad, no spaces #}
{{username}} {{tags|join(',')}}
{# ✅ good #}
{{ username }} {{ tags | join(',') }}
```

## Credits

- [Guo Yunhe](https://github.com/guoyunhe)

## 参考资料
## References

- [Code Guide by @mdo](http://codeguide.co)
- [Google HTML/CSS Style Guide](https://google.github.io/styleguide/htmlcssguide.html)

[EJS]: https://ejs.co/
[Nunjucks]: https://mozilla.github.io/nunjucks/
18 changes: 18 additions & 0 deletions docs/coding/html.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,24 @@ order: 1

了解更多 HTML 可访问性的知识,可以阅读[这篇 MDN 的文章](https://developer.mozilla.org/zh-CN/docs/learn/Accessibility)

## 模板语言

有非常多不同的模板语言被用来动态生成 HTML 文件,例如 [Nunjucks], [EJS]。编写模板语言代码时,也应该遵循一些常见规约。

此部分以 [Nunjucks] 作为示例,但是同样也适用于其他模板语言。

### 变量,过滤器和关键字必须有前后空格

等级: **强制**

```jinja
{# ❌ 错误,没有空格 #}
{{username}} {{tags|join(',')}}
{# ✅ 正确 #}
{{ username }} {{ tags | join(',') }}
```

## 作者署名

- [郭云鹤(鹤仙)](https://github.com/guoyunhe)
Expand Down

0 comments on commit 215fece

Please sign in to comment.