Histone - Java Implementation

Java implementation for Histone Template Engine

License

License

Categories

Categories

Java Languages
GroupId

GroupId

com.github.megafonweblab.histone
ArtifactId

ArtifactId

parent-histone-java-v2
Last Version

Last Version

1.9.2
Release Date

Release Date

Type

Type

pom
Description

Description

Histone - Java Implementation
Java implementation for Histone Template Engine

Download parent-histone-java-v2

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.megafonweblab.histone/parent-histone-java-v2/ -->
<dependency>
    <groupId>com.github.megafonweblab.histone</groupId>
    <artifactId>parent-histone-java-v2</artifactId>
    <version>1.9.2</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/com.github.megafonweblab.histone/parent-histone-java-v2/
implementation 'com.github.megafonweblab.histone:parent-histone-java-v2:1.9.2'
// https://jarcasting.com/artifacts/com.github.megafonweblab.histone/parent-histone-java-v2/
implementation ("com.github.megafonweblab.histone:parent-histone-java-v2:1.9.2")
'com.github.megafonweblab.histone:parent-histone-java-v2:pom:1.9.2'
<dependency org="com.github.megafonweblab.histone" name="parent-histone-java-v2" rev="1.9.2">
  <artifact name="parent-histone-java-v2" type="pom" />
</dependency>
@Grapes(
@Grab(group='com.github.megafonweblab.histone', module='parent-histone-java-v2', version='1.9.2')
)
libraryDependencies += "com.github.megafonweblab.histone" % "parent-histone-java-v2" % "1.9.2"
[com.github.megafonweblab.histone/parent-histone-java-v2 "1.9.2"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

  • core
  • java-compiler
  • spring
  • test

Histone Template Engine 2 Build Status Coverage Status Maven Central

Histone — powerful and flexible template engine, which can be used for HTML - code generation as well as any other kind of text - documents. Histone implementations exists for the web - browser as well as for the server (Java and PHP), it allows you to use same templates on the server and on the client. Built - in extension mechanism allows you to extend default template engine features, by adding your own methods and properties for the particular project. Templates has clean and simple syntax and can be stored either as source code or as compiled code that can be executed with the maximum performance wherever it's needed.

Histone Template Engine Java Implementation

Documentation

Using Histone from Maven

To use histone in your maven project you should add new maven dependency to your pom.xml

<dependency>
    <groupId>com.github.megafonweblab.histone</groupId>
    <artifactId>histone-java-v2</artifactId>
    <version>1.0.1</version>
</dependency>

Sources tree

Standart Maven project structure. |- src/ project sources |- assembly/ file with maven-assembly-plugin assembly descriptor |- etc/ file for maven-licence-plugin checks |- main/ main sources |- test/ tests sources

Distribution archive contents

|- libs/ histone-java dependency libraries
|- histone-java-A.B.C.jar histone-java library
|- LICENSE.txt Apache v2.0 license file
|- NOTICE.txt file with copyright info
|- README.md this file

Clone, Build and Run test

For Windows users before clone repo:

git config —global core.autocrlf false

Clone repo:

git clone https://github.com/MegafonWebLab/histone-java2 histone-java2

Go to the repo:

cd histone-java2

Run test:

mvn clean test

Build and Run test:

mvn clean package

Base Example:

import ru.histone.v2.evaluator.Context;
import ru.histone.v2.evaluator.Evaluator;
import ru.histone.v2.evaluator.resource.HistoneResourceLoader;
import ru.histone.v2.evaluator.resource.SchemaResourceLoader;
import ru.histone.v2.parser.Parser;
import ru.histone.v2.parser.node.ExpAstNode;
import ru.histone.v2.property.DefaultPropertyHolder;
import ru.histone.v2.rtti.RunTimeTypeInfo;

import java.util.LinkedHashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Example {
    public static void main(String[] args) {
        // for evaluating AST-tree
        final Evaluator evaluator = new Evaluator();
        // for parsing string template
        final Parser parser = new Parser();
        // base executor service
        final ExecutorService executorService = Executors.newFixedThreadPool(10); 
        // base resource loader
        final HistoneResourceLoader loader = new SchemaResourceLoader(executorService);
        // singleton with predefined functions
        final RunTimeTypeInfo runTimeTypeInfo = new RunTimeTypeInfo(executorService, loader, evaluator, parser); 
        final String baseUri = "http://localhost/";
        // context for evaluating
        final Context ctx = Context.createRoot(baseUri, runTimeTypeInfo, new DefaultPropertyHolder()); 
        
        // parsing template and create AST-tree
        final ExpAstNode node = parser.process("{{var x = 'Hello world!!'}}{{x}}", baseUri);
        // evaluate AST-tree
        final String res = evaluator.process(node, ctx);
        
        System.out.println(res);
    }
}
com.github.megafonweblab.histone

Megafon WebLab

Versions

Version
1.9.2
1.9.1
1.9.0
1.8.0
1.7.3
1.7.2
1.7.1
1.7.0
1.6.0
1.5.1
1.5.0
1.4.1
1.4.0
1.3.5
1.3.4
1.3.3