Language Name:pug File Extensions:.pug, .jade Description: Clean, whitespace-sensitive HTML template engine
//- Variables- const title = "Welcome to Pug"- const items = ["Apple", "Banana", "Cherry"]- const user = { name: "Alice", age: 25 }//- Doctypedoctype htmlhtml(lang="en") head meta(charset="UTF-8") meta(name="viewport" content="width=device-width, initial-scale=1.0") title= title body //- Simple tags h1.title.primary Welcome p.description This is a paragraph //- ID and classes div#container.wrapper.main-content h2 Content Section //- Attributes a(href="https://example.com" target="_blank") Click here img(src="image.jpg" alt="Description") //- Interpolation p Hello, #{user.name}! p You are #{user.age} years old //- Conditionals if user.age >= 18 p You are an adult else p You are a minor //- Loops ul.item-list each item in items li.item= item //- Case statement - const day = "Monday" case day when "Monday" p Start of the week when "Friday" p Almost weekend! default p Regular day //- Mixins mixin button(text, type = "primary") button(class=`btn btn-${type}`) = text +button("Submit") +button("Cancel", "secondary") //- Includes (for partials) //- include header.pug //- include footer.pug
Language Name:haml File Extensions:.haml Description: HTML abstraction markup language
-# Variables- title = "Welcome to Haml"- items = ["Apple", "Banana", "Cherry"]- user = {name: "Alice", age: 25}!!! 5%html{lang: "en"} %head %meta{charset: "UTF-8"}/ %meta{name: "viewport", content: "width=device-width, initial-scale=1.0"}/ %title= title %body -# Tags with classes and IDs %h1.title.primary Welcome to Haml %p.description This is a paragraph %div#container.wrapper %h2 Content Section -# Attributes %a{href: "https://example.com", target: "_blank"} Click here %img{src: "image.jpg", alt: "Description"}/ -# Interpolation %p Hello, #{user[:name]}! %p You are #{user[:age]} years old -# Conditionals - if user[:age] >= 18 %p You are an adult - else %p You are a minor -# Loops %ul.item-list - items.each do |item| %li.item= item -# Inline content %p This is a %strong bold word in a sentence.
{# Variables #}{% set title = "Twig Template" %}{% set user = { name: "Alice", age: 25 } %}<div> <h1>{{ title }}</h1> <p>{{ user.name | upper }}</p> {% if user.age > 18 %} <p>Adult</p> {% endif %} {% for i in 1..5 %} <li>Item {{ i }}</li> {% endfor %}</div>