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

https://github.com/patriziobruno/mochatemplate

MochaTemplate is a template library inspired by Adobe Sightly. It leverages the power of server-side Javascript to clearly separate presentation and logic concerns.
https://github.com/patriziobruno/mochatemplate

adobe javascript servlet sightly template-engine

Last synced: 5 months ago
JSON representation

MochaTemplate is a template library inspired by Adobe Sightly. It leverages the power of server-side Javascript to clearly separate presentation and logic concerns.

Awesome Lists containing this project

README

          

# mochatemplate
[![license](https://img.shields.io/github/license/patriziobruno/mochatemplate.svg)](https://raw.githubusercontent.com/patriziobruno/mochatemplate/master/LICENSE)
[![Build Status](https://travis-ci.org/patriziobruno/mochatemplate.svg?branch=master)](https://travis-ci.org/patriziobruno/mochatemplate)
[![Coverage Status](https://coveralls.io/repos/github/patriziobruno/mochatemplate/badge.svg?branch=master)](https://coveralls.io/github/patriziobruno/mochatemplate?branch=master)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/11225/badge.svg?flat=1)](https://scan.coverity.com/projects/patriziobruno/mochatemplate)

A template library inspired by Adobe Sightly (https://docs.adobe.com/ddc/en/gems/introduction-to-sightly.html).

It makes use of:
- jsoup (https://jsoup.org/) for HTML parsing
- Reflections (https://github.com/ronmamo/reflections) for runtime loading of template-nodes interpreters
- JDK native script engine (Nashorn for JDK8, Rhino for JDK7)

To use the library in your application you can either instantiate MochaTemplateEngine from your servlet or add net.desertconsulting.mochatemplate.servlet.MainServlet to your web.xml.

### Test
To run unit tests:
```bash
$ mvn test
```

To run a jetty instance serving the included example:
```bash
$ mvn jetty:run
```

### Example template
```html



var Person = importClass(Packages.examples.Person);
var query = request.getParameter('search');




${person.FullName}



```