Print Hello World! on screen by Python Jinja2 and Go html/template
respectively.
Python Jinja2:
jinja2-example-1.py |
repository |
view raw
| #!/usr/bin/env python
# -*- coding:utf-8 -*-
from jinja2 import Template
import sys
if __name__ == '__main__':
tmpl = Template("Hello {{ name }}!")
sys.stdout.write(tmpl.render(name="World"))
|
Go html/template:
html-template-example-1.go |
repository |
view raw
| package main
import (
"html/template"
"os"
)
func main() {
t, _ := template.New("foo").Parse(`Hello {{.}}!`)
t.Execute(os.Stdout, "World")
}
|
Tested on: Ubuntu Linux 14.10, Go 1.4, Python 2.7.8, Jinja2 2.7.3
Golang html/template versus Python Jinja2 series: