GithubHelp home page GithubHelp logo

htmlski's Introduction

htmlski

A HTML based templating language

<!-- Variables -->
{{ value }}
{{ foo.value }}
{{ foo['value'] }}

{{{ rawHtml }}} - Triple brackets won't be escaped

<!-- Global Variables -->
{{ _self }} - The current template
{{ _context }} - The current context

<!-- Settings Variables -->
{{> set myVar = 'Hello world' }}

<!-- If -->
<div if="myVar === true">
	Hello
</div>

<div elseif="myVar === false">
	World
</div>

<div else>
	!!!
</div>

<!-- Loops -->
<ul>
	<!-- Iterating over an array -->
	<li for="value in rows">
		{{ value.name }}
	</li>
</ul>

<ul>
	<!-- Iterating over key/value pairs (key is optional) -->
	<li for="key, value in rows">
		{{ key }}: {{ value }}
	</li>
</ul>

<ul>
	<!-- Loops are injected with the `loop` variable -->
	<li for="a in b">
		{{ loop.index }} - Current iteration index (0 indexed)
		{{ loop.first }} - Bool, true if first iteration
		{{ loop.last }} - Bool, true if last iteration
	</li>
</ul>

<ul>
	<!-- Loops can be combined with if -->
	<li for="row in rows" if="row.enabled === true">
		{{ row.title }}
	</li>
	<li else>
		Row disabled
	</li>
</ul>

<!-- Import -->
<!-- You can import templates for easy re-use -->
<!-- input.html -->
<link rel="export" as="Input" />
<meta is="prop" name="label" typeof="string" content="Default Label" />
<meta is="prop" name="type" typeof="string" /><!-- No content means prop is required? -->

<label>
	<span>{{ label }}</span>
	<input 
		type="{{ type }}"
	/>
	{{{ children }}}
</label>

<!-- form.html -->
<link rel="import" href="input.html" />
<link rel="import" href="button.html" as="MyButton" />

<Input label="Name" type="text">
	<span>Some children</span>
</Input>

<MyButton>Hello</MyButton>

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.