Git Product home page Git Product logo

spring-boot-starter-jade4j's Introduction

Spring Boot jade4j Starter

Build Status Coverage Status Apache License 2 Gitter


This Starter provides you the minimal and required configuration to use jade templates as views in your Spring Boot application.

Behind the scenes, this starter uses the jade4j and spring-jade4j libraries.

Environment

JDK Spring Framework Spring Boot

Download

Maven Central Download

JCenter Download

Issues

Stories in Ready

Throughput Graph

GitHub, Factoids and Stats

Forks Release Issues


Usage

The usage is pretty straightforward as you can expect for any Spring Boot Starter.

Add Maven dependency

build.gradle

...
dependencies {
  compile "com.domingosuarez.boot:spring-boot-starter-jade4j:0.3.1"
}
...

pom.xml

<project>
  ...
  <dependencies>
    <dependency>
      <groupId>com.domingosuarez.boot</groupId>
      <artifactId>spring-boot-starter-jade4j</artifactId>
      <version>0.3.1</version>
    </dependency>
  </dependencies>
</project>

Jade templates

Add the jade templates in the following directory

src
└── main
    └── resources
        └── templates
            └── index.jade

Then you can add new Spring MVC controllers as usual


Helpers

You can add helpers automatically using the annotation @JadeHelper

package demo;

import com.domingosuarez.boot.autoconfigure.jade4j.JadeHelper;

@JadeHelper
public class Util {
  public String format(double number) {
    return "some formating";
  }
}

template.jade

html
  head
    title Hello
  body
    h
    h1
      #{util.format(4)} # (1)
  1. The helper name’s is the Spring Bean id

Customize the helper’s name

You can customize the helper’s name using the JadeHelper annotation

package demo;

import com.domingosuarez.boot.autoconfigure.jade4j.JadeHelper;

@JadeHelper("myId") // (1)
public class Util {
  public String format(double number) {
    return "some formating";
  }
}
  1. The new id

template.jade

html
  head
    title Hello
  body
    h
    h1
      #{myId.format(4)}

Configuration

The following settings are available:

Setting key Type Default value

spring.jade4j.checkTemplateLocation

Boolean

true

spring.jade4j.prefix

String

'classpath:/templates/'

spring.jade4j.suffix

String

'.jade'

spring.jade4j.encoding

String

'UTF-8'

spring.jade4j.caching

Boolean

true

spring.jade4j.prettyPrint

Boolean

false

spring.jade4j.mode

String

'HTML'

spring.jade4j.contentType

String

'text/html'

spring.jade4j.resolver.order

Integer

Ordered.LOWEST_PRECEDENCE - 50


Complete demo application

Please take a look into this application if you want to checkout a fully application.

spring-boot-starter-jade4j's People

Contributors

domix avatar mcgois avatar nikos avatar xiaoyuelang avatar gitter-badger avatar

Watchers

James Cloos avatar  avatar

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.