Jade Template Engine: Unterschied zwischen den Versionen
Aus Wikizone
(Die Seite wurde neu angelegt: „Jade ist eine auf node basierte HTML Template Engine, mit der man vereinfachtes html schreiben kann, das dann on the fly in html übersetzt wird. Damit kann ma…“) |
|||
| Zeile 6: | Zeile 6: | ||
=== Installieren === | === Installieren === | ||
Node muss vorhanden sein | Node muss vorhanden sein | ||
| − | npm install jade --global | + | npm install jade --global |
| + | |||
| + | === HTML Files erstellen === | ||
| + | 1. Jade File z.B. | ||
| + | |||
| + | index.jade | ||
| + | <pre> | ||
| + | doctype html | ||
| + | html(lang="de") | ||
| + | head | ||
| + | meta(charset="utf-8") | ||
| + | title BlackBird Co. | ||
| + | meta(name="description", content="") | ||
| + | meta(name="author", content="") | ||
| + | meta(name="viewport", content="width=device-width, initial-scale=1") | ||
| + | link(rel="stylesheet", href="css/style.css") | ||
| + | link(rel="icon", type="image/png", href="images/favicon.png") | ||
| + | |||
| + | body | ||
| + | |||
| + | header.bird-box | ||
| + | .back-bird | ||
| + | ... | ||
| + | </pre> | ||
| + | 2. Den Watcher im Verzeichnis starten: | ||
| + | |||
| + | jade -w . | ||
| + | Jedesmal wenn das .jade File gespeichert wird, wird auch ein html File generiert. | ||
| + | </pre> | ||
== Command Line == | == Command Line == | ||
Version vom 3. Juli 2018, 16:00 Uhr
Jade ist eine auf node basierte HTML Template Engine, mit der man vereinfachtes html schreiben kann, das dann on the fly in html übersetzt wird. Damit kann man sehr schnell Code entwickeln. Man kann Jade auch einfach als Tool nehmen um schnell Code zu schreiben
https://t3n.de/news/jade-638027/
Quickstart
Installieren
Node muss vorhanden sein
npm install jade --global
HTML Files erstellen
1. Jade File z.B.
index.jade
doctype html
html(lang="de")
head
meta(charset="utf-8")
title BlackBird Co.
meta(name="description", content="")
meta(name="author", content="")
meta(name="viewport", content="width=device-width, initial-scale=1")
link(rel="stylesheet", href="css/style.css")
link(rel="icon", type="image/png", href="images/favicon.png")
body
header.bird-box
.back-bird
...
2. Den Watcher im Verzeichnis starten:
jade -w .
Jedesmal wenn das .jade File gespeichert wird, wird auch ein html File generiert.
Command Line
Command Line
$ jade [options] [dir|file ...] Options:
-h, --help output usage information
-V, --version output the version number
-O, --obj <path|str> JavaScript options object or JSON file containing it
-o, --out <dir> output the compiled html to <dir>
-p, --path <path> filename used to resolve includes
-P, --pretty compile pretty html output
-c, --client compile function for client-side runtime.js
-n, --name <str> the name of the compiled template (requires --client)
-D, --no-debug compile without debugging (smaller functions)
-w, --watch watch files for changes and automatically re-render
-E, --extension <ext> specify the output file extension
--name-after-file name the template after the last section of the file path
(requires --client and overriden by --name)
--doctype <str> specify the doctype on the command line (useful if it
is not specified by the template) Examples Translate jade the templates dir:
$ jade templates
Create {foo,bar}.html
$ jade {foo,bar}.jade
Jade over stdio
$ jade < my.jade > my.html
Jade over stdio
$ echo "h1 Jade!" | jade
foo, bar dirs rendering to /tmp
$ jade foo bar --out /tmp