org.rendersnake:rendersnake-tryouts

fast HTML generation libary for Web applications

License

License

GroupId

GroupId

org.rendersnake
ArtifactId

ArtifactId

rendersnake-tryouts
Last Version

Last Version

1.8
Release Date

Release Date

Type

Type

jar
Description

Description

fast HTML generation libary for Web applications

Download rendersnake-tryouts

How to add to project

<!-- https://jarcasting.com/artifacts/org.rendersnake/rendersnake-tryouts/ -->
<dependency>
    <groupId>org.rendersnake</groupId>
    <artifactId>rendersnake-tryouts</artifactId>
    <version>1.8</version>
</dependency>
// https://jarcasting.com/artifacts/org.rendersnake/rendersnake-tryouts/
implementation 'org.rendersnake:rendersnake-tryouts:1.8'
// https://jarcasting.com/artifacts/org.rendersnake/rendersnake-tryouts/
implementation ("org.rendersnake:rendersnake-tryouts:1.8")
'org.rendersnake:rendersnake-tryouts:jar:1.8'
<dependency org="org.rendersnake" name="rendersnake-tryouts" rev="1.8">
  <artifact name="rendersnake-tryouts" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.rendersnake', module='rendersnake-tryouts', version='1.8')
)
libraryDependencies += "org.rendersnake" % "rendersnake-tryouts" % "1.8"
[org.rendersnake/rendersnake-tryouts "1.8"]

Dependencies

compile (4)

Group / Artifact Type Version
org.rendersnake : rendersnake jar 1.8
org.apache.commons : commons-lang3 jar 3.1
javax.servlet : servlet-api jar 2.4
junit : junit jar 4.8.2

Project Modules

There are no modules declared in this project.

rendersnake

RenderSnake is a Java library for creating components and pages that produce HTML using only Java. Its purpose is to support the creation of Web applications that are better maintainable, allows for easier reuse, have testable UI components and produces compact HTML in an efficient way.

Hello example

HtmlCanvas html = new HtmlCanvas();
html
  .html()
    .body()
       .h1().content("Hello Coder")
    ._body()
  ._html();
System.out.println(html.toHtml());

Example of a complex Form element to pick one of four options

html.div(dataRole("fieldcontain"))
    .fieldset(dataRole("controlgroup").dataType("horizontal"))
        .legend().content("Method")
        .input(type("radio").name("method").id("radio-get").value("method-get").checked("checked").onChange("clickedMethod(this.value);"))
        .label(for_("radio-get")).content("GET")
        
        .input(type("radio").name("method").id("radio-post").value("method-post").onChange("clickedMethod(this.value);"))
        .label(for_("radio-post")).content("POST")
        
        .input(type("radio").name("method").id("radio-put").value("method-put").onChange("clickedMethod(this.value);"))
        .label(for_("radio-put")).content("PUT")
        
        .input(type("radio").name("method").id("radio-delete").value("method-delete").onChange("clickedMethod(this.value);"))
        .label(for_("radio-delete")).content("DELETE")
    ._fieldset()
    ._div();

Example of a HTML5 page wrapper and JQuery Mobile

public class MobileSiteLayoutWrapper extends RenderableWrapper {

    public MobileSiteLayoutWrapper(Renderable component) {
        super(component);
    }

    @Override
    public void renderOn(HtmlCanvas html) throws IOException {
        html
        .render(DocType.HTML5)
        .html()
            .head()
                .title().content("renderSnake - Mobile")
                .render(JQueryLibrary.mobileTheme("1.0"))
                .render(JQueryLibrary.core("1.6.4"))
                .render(JQueryLibrary.mobile("1.0"))
            ._head()
        .body()
            .div(dataRole("page"))
                .div(dataRole("header").dataTheme("b"))
                    .render(new PageHeader())
                    ._div()
                .div(dataRole("content").dataTheme("b"))
                    .render(this.component)
                    ._div()
                .div(dataRole("footer").dataTheme("b"))
                    .render(new PageFooter())
                    ._div()
            ._div()
        ._body()
        ._html();
    }
}

Example of a login component

public class LoginPageContent implements Renderable {

    @Override
    public void renderOn(HtmlCanvas html) throws IOException {// @formatter:off

        html.form(action("/login").method("post").id("login-form"))
            .fieldset()
                .div(dataRole("fieldcontain"))
                    .label(for_("name")).content("Username")                    
                    .input(type("text").name("name").id("name"))                    
                ._div()
                .div(dataRole("fieldcontain"))
                    .label(for_("password")).content("Password")
                    .input(type("password").name("password").id("password"))                    
                ._div()
                .input(type("submit").value("Login"))
            ._fieldset()
            ._form();                                               
    }        
}

Maven Installation (available in Maven Central)

<properties>
	<rendersnake.version>1.9.0</rendersnake.version>
</properties>

<dependency>
	<groupId>org.rendersnake</groupId>
	<artifactId>rendersnake</artifactId>
	<version>${rendersnake.version}</version>
</dependency>
```

Versions

Version
1.8