Code Snippet - How to Use Variable with Jade

2014/05/311 min read
bookmark this
Responsive image

Table of Contents

  1. Introduction
  2. Jade Variable Example
  3. Conclusion

Introduction

The following is a quick example of how to use variables in Jade (Pug) templates.

Jade Variable Example

The following h1 will display "hello, h1 will be this."

- foo = "hello, h1 will be this." h1=foo

More Examples

More examples can be found at the Jade Variable example page.

Conclusion

Using variables in Jade (Pug) templates is straightforward — define the variable and reference it directly in your HTML elements.