GithubHelp home page GithubHelp logo

ivartj / tpl Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 28 KB

Template system for making simple static websites. The code is currently a mess.

C 98.45% Makefile 1.01% M4 0.54%

tpl's Introduction

tpl template system (unfinished)
===================

tpl is a tool for composing simple HTML documents. The following
are notes on how I intend it to work.

==== build.sh
#!/bin/bash
cd en
for i in $(find . -name '*.bb'); do
	tpl -d ../dest/en -I ../tpl/ -D doc-path="$i" "$i"
done

cd ../no
for i in $(find . -name '*.bb'); do
	tpl -d ../dest/no -I ../tpl/no/ -I ../tpl/ -D doc-path="$i" "$i"
done

==== tpl/body.html.tpl
-outputs: html
title: Untitled
lang: en
lang-other: no

<html lang="<[lang]>">
	<head>
		<meta charset="utf-8">
		<title><[title|html-escape]></title>
	</head>
	<body>
		<a href="/<[lang-other]>/<[doc-path]>"><[lang-other]></a>
		<h1><[title|html-escape]></h1>
		<[...]>
	</body>
</html>

==== tpl/no/body.html.tpl
-template: body.html
title: Ingen tittel
lang: no
lang-other: en

<[...]>

==== tpl/bb.tpl
-template: body.html

<[...|bbcode]>

==== en/hello.bb
title: Hello

[b]Hello![/b]

==== no/hello.bb
title: Hallo

[b]Hallo![/b]

==== dest/en/hello.html
<html lang="en">
	<head>
		<meta charset="utf-8">
		<title>Hello</title>
	</head>
	<body>
		<a href="/no/hello.html>">no</a>
		<h1>Hello</h1>
		<strong>Hello!</strong><br />
	</body>
</html>

==== dest/no/hello.html
<html lang="no">
	<head>
		<meta charset="utf-8">
		<title>Hallo</title>
	</head>
	<body>
		<a href="/en/hello.html>">en</a>
		<h1>Hallo</h1>
		<strong>Hallo!</strong><br />
	</body>
</html>

==== Template merging

If a template refers to a template for its own extension, tpl will
search only later search directories.

start			-> no/hello.bb

no/hello.bb		-> tpl/bb.tpl
tpl/bb.tpl
 -template: body.html	-> tpl/no/body.html.tpl
tpl/no/body.html.tpl
 - template body.html	-> tpl/body.html
tpl/body.html


title: Hallo		-> title: Hallo
-
title: Ingen tittel
lang: no		-> lang: no
lang-other: en		-> lang-other: en
-
title: Untitled
lang: en
lang-other: no

merge template

==== Programmatic features

While fields in a template are written as <[field]>, control structures
may be written like <{if Approved}> or <{for articles/*/summary.*}> followed
by <{end}>.

tpl's People

Contributors

ivartj avatar

Watchers

James Cloos avatar  avatar oddbjol avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.