3.0.0 • Published 9 years ago

taya v3.0.0

Weekly downloads
12
License
MIT
Repository
github
Last release
9 years ago

Taya

Presentation

Taya is a JavaScript fast and beautiful engine.

Here is an example.

@each (user in users)
	{ user.name }

	@if (user.publishEmail)
		{ user.email }
	@end
@end

Syntax

The syntax is very simple.

Condition

@if (condition)

@elif (anotherCondition)

@else

@end
@unless (condition)

@else

@end

Foreach loop

@each (value in list)
	{ value.thing }
@end

Execute

@execute (result = 'test')

Print

{ Math.random() }

Escape

!@escaped
!{ also }

API

First, install the NPM package: npm install taya

Taya

The Taya class represents a template.

import Taya from 'taya';

let template = new Taya('{{ hello }}');
Taya#render(context, escape)

Renders a Taya template with a context, and the escape function.

By default, context is an empty object, and escape is an HTML escape function.

import Taya from 'taya';

let template = new Taya('{{ hello }}');

template.render({
	hello: 'Hello World'
}) === 'Hello World';
Taya.render(source, context, escape)

Render a taya source with a context and an escape function. See above for the parameters.

Taya.renderFile(path, context, escape)

Renders a taya file (use a cache) and return a promise. See above for context and escape parameters.

import Taya from 'taya';

Taya.renderFile('test.tay').then(function(result) {
	console.log(result);
});
3.0.0

9 years ago

2.1.0

9 years ago

2.0.0

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago