GithubHelp home page GithubHelp logo

beaufortfrancois / templates Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 1.0 355 KB

License: Apache License 2.0

CoffeeScript 5.88% JavaScript 0.43% Makefile 0.03% Python 12.17% Shell 0.93% Java 80.56%

templates's Introduction

Motemplate templates

Motemplate is a mostly-logicless data-binding templating language, initially inspired by mustache and ctemplate but with stronger data-binding and logic primitives.

The goal of Motemplate is to provide high quality templates across the whole stack of a web application. Write templates once, statically render content on the Java/Python/node server, then as content is added, dynamically render it using the same templates on the JavaScript client. This means:

  • Minimal logic (not logic-less but pretty dumb).
  • Powerful data-binding primitives.

The reference implementation of Motemplate is written in Python. The other platforms (Java and JavaScript) lag quite far behind - not only are they missing newer features, but they haven't even been renamed to Motemplate yet.

Overview

A template is text plus {{/}}-style markup, for example,

<h1>Party shopping list</h1>
<ul>
{{#guest:guests}}
  <li>{{guest.name}} - {{guest.favorites.food}}
  {{?guest.favourites.color}}
  <li>{{guest.name}} - {{guest.favorites.color}}
  {{/guest.favourites.color}}
{{/guests}}
</ul>

...

{
  "guests": [{
    "name": "Ben",
    "favorites": {
      "food": "Spaghetti",
      "color": "Blue"
    }
  },{
    "name": "Fred",
    "favorites": {
      "food": "Penne"
    }
  }]
}

A template is rendered by passing it object data. The types vary per implementation:

  • Python uses any object which declares a get() method - such as dicts.
  • Java reflects over properties and maps.
  • JavaScript uses objects.

The End

Unfortunately, that's all the documentation for now. I haven't had time to keep it up to date with the development needed to support Chromium's Docserver, so I've deleted it, but you can attempt to glance at the templates in Chromium (especially these) and the test cases in this repository.

templates's People

Contributors

beaufortfrancois avatar kalman avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

mikepipo

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.