All Projects → Joker → Jade

Joker / Jade

Licence: bsd-3-clause
Jade.go - pug template engine for Go (golang)

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Jade

Pug
Pug template engine for PHP
Stars: ✭ 341 (+35.86%)
Mutual labels:  template, template-engine, pug, jade
Email Templates
📫 Create, preview, and send custom email templates for Node.js. Highly configurable and supports automatic inline CSS, stylesheets, embedded images and fonts, and much more!
Stars: ✭ 3,291 (+1211.16%)
Mutual labels:  templates, template, template-engine, pug
Node.js Bootstrap Starter Template
Node.js, Express, Pug, Twitter Bootstrap, Starter Template
Stars: ✭ 107 (-57.37%)
Mutual labels:  template, pug, jade
Pongo2
Django-syntax like template-engine for Go
Stars: ✭ 2,111 (+741.04%)
Mutual labels:  templates, template, template-engine
tale-pug
Tale Pug is the popular JavaScript Template Engine Pug, formerly Jade, for PHP!
Stars: ✭ 32 (-87.25%)
Mutual labels:  template-engine, pug, jade
Mikado
Mikado is the webs fastest template library for building user interfaces.
Stars: ✭ 323 (+28.69%)
Mutual labels:  templates, template, template-engine
pypugjs
PugJS syntax adapter for Django, Jinja2 and Mako templates
Stars: ✭ 237 (-5.58%)
Mutual labels:  template-engine, pug, jade
Phug
Phug - The Pug Template Engine for PHP
Stars: ✭ 43 (-82.87%)
Mutual labels:  template, template-engine, pug
Jade Html5 Boilerplate
HTML5 Boilerplate ported to Jade. Great as a drop and go markup skeleton for Express apps.
Stars: ✭ 111 (-55.78%)
Mutual labels:  template, pug, jade
Laravel Pug
Pug view adapter for Laravel and Lumen
Stars: ✭ 130 (-48.21%)
Mutual labels:  pug, jade
Westwind.razorhosting
Hosting the Razor Runtime outside of ASP.NET/MVC for use in non-Web .NET applications.
Stars: ✭ 136 (-45.82%)
Mutual labels:  template, template-engine
Aeromock
Lightweight mock web application server
Stars: ✭ 152 (-39.44%)
Mutual labels:  template-engine, jade
String template
A template engine for Rails, focusing on speed, using Ruby's String interpolation syntax
Stars: ✭ 122 (-51.39%)
Mutual labels:  template, template-engine
Open React Template
A free React landing page template designed to showcase open source projects, SaaS products, online services, and more. Made by
Stars: ✭ 1,956 (+679.28%)
Mutual labels:  templates, template
Kotlin Gradle Plugin Template
🐘 A template to let you started with custom Gradle Plugins + Kotlin in a few seconds
Stars: ✭ 141 (-43.82%)
Mutual labels:  templates, template
Seven
Eleventy template using Bootstrap, Sass, Webpack, Vue.js powered search, includes lots of other features
Stars: ✭ 114 (-54.58%)
Mutual labels:  templates, template
Windowstemplatestudio
Windows Template Studio quickly builds a UWP app, using a wizard-based UI to turn your needs into a foundation of Windows 10 patterns and best practices.
Stars: ✭ 2,089 (+732.27%)
Mutual labels:  template, template-engine
Preview Email
Automatically opens your browser to preview Node.js email messages sent with Nodemailer. Made for Lad!
Stars: ✭ 112 (-55.38%)
Mutual labels:  templates, pug
Latex Koma Template
Generic template for midsize and larger documents based on KOMA script classes.
Stars: ✭ 151 (-39.84%)
Mutual labels:  templates, template
Bootstrap3 Pug Former jade Node Express Grunt
Bootstrap 3 templated by Jade
Stars: ✭ 242 (-3.59%)
Mutual labels:  pug, jade

Jade.go - template engine for Go (golang)

Package jade (github.com/Joker/jade) is a simple and fast template engine implementing Jade/Pug template.
Jade precompiles templates to Go code or generates html/template.
Now Jade-lang is renamed to Pug template engine.

GoDoc Go Report Card

Jade/Pug syntax

example:

//-  :go:func Index(pageTitle string, youAreUsingJade bool)

mixin for(golang)
    #cmd Precompile jade templates to #{golang} code.

doctype html
html(lang="en")
    head
        title= pageTitle
        script(type='text/javascript').
            if(question){
                answer(40 + 2)
            }
    body
        h1 Jade - template engine
            +for('Go')

        #container.col
            if youAreUsingJade
                p You are amazing
            else
                p Get on it!
            p.
                Jade/Pug is a terse and simple
                templating language with
                a #[strong focus] on performance 
                and powerful features.

becomes

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Jade.go</title>
        <script type="text/javascript">
            if(question){
                answer(40 + 2)
            }
        </script>
    </head>
    <body>
        <h1>Jade - template engine
            <div id="cmd">Precompile jade templates to Go code.</div>
        </h1>
        <div id="container" class="col">
            <p>You are amazing</p>
            <p>
                Jade/Pug is a terse and simple
                templating language with
                a <strong>focus</strong> on performance 
                and powerful features.
            </p>
        </div>
    </body>
</html>

Here are additional examples and test cases.

Example usage

jade command

jade -pkg=main -writer hello.jade

jade command precompiles hello.jade to hello.jade.go

hello.jade

:go:func(arg) word string
doctype 5
html
    body
        p Hello #{word}!

hello.jade.go

// Code generated by "jade.go"; DO NOT EDIT.
package main

import "io"

const (
    hello__0 = `<!DOCTYPE html><html><body><p>Hello `
    hello__1 = `!</p></body></html>`
)
func tpl_hello(word string, wr io.Writer) {
    buffer := &WriterAsBuffer{wr}
    buffer.WriteString(hello__0)
    WriteEscString(word, buffer)
    buffer.WriteString(hello__1)
}

main.go

package main
//go:generate jade -pkg=main -writer hello.jade

import "net/http"

func main() {
    http.HandleFunc("/", func(wr http.ResponseWriter, req *http.Request) {
        tpl_hello("jade", wr)
    })
    http.ListenAndServe(":8080", nil)
}

output at localhost:8080

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

github.com/Joker/jade packege

generate html/template at runtime (This case is slightly slower and doesn't support all features of Jade.go)

package main

import (
    "fmt"
    "html/template"
    "net/http"

    "github.com/Joker/hpp" // Prettify HTML
    "github.com/Joker/jade"
)

func handler(w http.ResponseWriter, r *http.Request) {
    jadeTpl, _ := jade.Parse("jade", []byte("doctype 5\n html: body: p Hello #{.Word} !"))
    goTpl, _ := template.New("html").Parse(jadeTpl)

    fmt.Printf("output:%s\n\n", hpp.PrPrint(jadeTpl))
    goTpl.Execute(w, struct{ Word string }{"jade"})
}

func main() {
    http.HandleFunc("/", handler)
    http.ListenAndServe(":8080", nil)
}

console output

<!DOCTYPE html>
<html>
    <body>
        <p>Hello {{.Word}} !</p>
    </body>
</html>

output at localhost:8080

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

Installation

$ go get github.com/Joker/jade/cmd/jade

Custom filter :go

This filter is used as helper for command line tool
(to set imports, function name and parameters).
Filter may be placed at any nesting level.
When Jade used as library :go filter is not needed.

Nested filter :func

:go:func
    CustomNameForTemplateFunc(any []int, input string, args map[string]int)

:go:func(name)
    OnlyCustomNameForTemplateFunc

:go:func(args)
    (only string, input float32, args uint)

Nested filter :import

:go:import
    "github.com/Joker/jade"
    github.com/Joker/hpp
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].