Skip to content
Jade.go - template engine for Go (golang)
Go HTML CSS
Branch: master
Clone or download
Pull request Compare This branch is 38 commits behind Joker:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
testdata
LICENSE.md
README.md
config.go
jade_lex.go
jade_node.go
jade_parse.go
jade_test.go
lex.go
node.go
parse.go
template.go

README.md

Jade.go - template engine for Go (golang)

Package jade (github.com/Joker/jade) implements Jade-lang templates for generating Go html/template output.
Now Jade-lang renamed to Pug template engine.

GoDoc Go Report Card

Jade syntax

example:

doctype html
html(lang="en")
  head
    title= pageTitle
    script(type='text/javascript').
      if (foo) {
         bar(1 + 5)
      }
  body
    h1 Jade - template engine
    #container.col
      if youAreUsingJade
        p You are amazing
      else
        p Get on it!
      p.
        Jade is #[a(terse)] and simple
        templating language with a
        #[strong focus] on performance
        and powerful features.
      + withGo

mixin withGo
  |Generating Go html/template output.

becomes

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>{{ pageTitle }}</title>
        <script type='text/javascript'>
            if (foo) {
                bar(1 + 5)
            }
        </script>
    </head>
    <body>
        <h1>Jade - template engine</h1>
        <div id="container" class="col">
            {{ if youAreUsingJade }}
                <p>You are amazing</p>
            {{ else }}
                <p>Get on it!</p>
            {{ end }}
            <p>
                Jade is <a terse="terse"></a> and simple
                templating language with a
                <strong>focus</strong> on performance
                and powerful features.
            </p>
            {{ template "withGo" }}
        </div>
    </body>
</html>

{{ define "withGo" }}
  Generating Go html/template output.
{{ end }}

Example usage

package main

import (
    "fmt"
    "github.com/Joker/jade"
)

func main() {
    tpl, err := jade.Parse("name_of_tpl", "doctype 5: html: body: p Hello world!")
    if err != nil {
        fmt.Printf("Parse error: %v", err)
        return
    }

    fmt.Printf( "Output:\n\n%s", tpl  )
}

Output:

<!DOCTYPE html>
<html>
    <body>
        <p>Hello world!</p>
    </body>
</html>

Installation

$ go get github.com/Joker/jade
You can’t perform that action at this time.