An open API service indexing awesome lists of open source software.

https://github.com/mariuslundgard/node-transclusion

[ALPHA]
https://github.com/mariuslundgard/node-transclusion

Last synced: 3 months ago
JSON representation

[ALPHA]

Awesome Lists containing this project

README

        

# Transclusion

Transclusion is an HTML5 preprocessor based on the DOM and the concept of _[transclusion](https://en.wikipedia.org/wiki/Transclusion)_ as defined by [Ted Nelson](https://en.wikipedia.org/wiki/Ted_Nelson) in 1982.

The purpose of Transclusion is to make life easier for anyone who knows a little bit of HTML, as well as laying the foundation for developers working with advanced HTML content editors.

*Transclusion is currently only implemented in PHP5.4+.*

[See the PHP version here](http://github.com/mariuslundgard/transclusion).

## Syntax examples

### Basic syntax

The syntax of Transclusion embraces/extends the XML-flavored syntax implemeneted by HTML5. Therefore, valid HTML5 is completely valid Transclusion syntax:
```html


Hello, world!

Hello world!

```

However, the following will produce the same output as the previous example:
```html
Hello, world!

Hello world!


```

This is because Transclusion lets you omit unecessary markup (although this does require a good understanding of the way XML and HTML5 is structured).

Here's a more advanced example where the `header` element needs a closing tag in order to produce the intended structure:
```html

A More Advanced “Hello, World!” Example

[[ title ]]


A “Hello, world!” example is a common way of introducing a scripting language.


```

Which will output:
```html


A More Advanced “Hello, World!” Example


A More Advanced “Hello, World!” Example




A “Hello, world!” example is a common way of introducing a scripting language.


```

### Including element blocks

```html

The element following this paragraph will be the element with the corresponding id "intro" in "source.html".


```

### Base documents and block replacement

In _Extension.html_:
```html

This replaces the div#content element in the base document.

```

In _Base.html_:
```html
[[ title ]]


(Content goes here.)

```

### Expressions

Transclusion uses the expression delimiters `[[` and `]]` (without the quotes). In the following example, the document variable `title` is used as an example.

```html

The following header's text will be the document filename (if the title was not otherwise set using the setter routine).


[[ title ]]


```

### Operations

```html

The sum of 3 + 7 is [[ 3 + 7 ]]


```

### Iterations

```html

```

### Conditions

```html



[[ post.title ]]





No posts



```

### Document variables

* `title` -- Refers to the document title (the filename by default)
* `uri`
* `last_modified`
* `meta.author` -- Refers to the content atrribute of the `` element
* `meta.description`
* `meta.keywords`
* `meta.*`
* `directory.title`
* `directory.documents`
* `directory.stylesheets`
* `directory.scripts`
* `directory.files`
* `directory.resources`

## Implementations

### Official
* PHP5.4+ (in development)
* Node.js (in development)