Giter Club home page Giter Club logo

grails-jade's Introduction

Build Status

GRAILS JADE PLUGIN

The Grails Jade plugin allows you to replace or use in conjunction jade files with Grails views. This plugin is a wrapper for jade4j and spring-jade4j. There are several working examples in the plugin source in version control that will help you get started.

CONFIGURATION

The plugin allows customization on how the jade is rendered via a few different configuration options. Below is the default configuration that is bundled. To change the configuration simple add the block below to your Config.grooy and change the values. You only need to add the values you with to replace as the default config will be merged with yours.

JadeDefaultConfig.groovy
grails {
	plugin {
		jade {
			/* Format the HTML or compress the output by removing unecessary whitespace. */
			prettyPrint = true

			/* Store the parsed template or reparse for every request. */
			caching = true

			/* Render exceptions in view or fail silently. */
			renderExceptions = true

			/* Additional filters for embedding different content types in a template, such as markdown, coffeescript */
			filters = [:]

			/* Default objects available to all templates. */
			sharedVariables = [:]
		}
	}
}

Coffeescript Filter

To add filtering for coffeescript you would need to add coffeescript-jade-filter and jcoffeescript to your path via lib or maven and add the following to your application.

BuildConfig.groovy
dependencies {
    compile('jade4j-coffeescript-filter:jade4j-coffeescript-filter:0.2.0',
            'jcoffeescript:jcoffeescript:1.1')
    ...
}
Config.groovy
import de.neuland.jade4j.filter.CoffeeScriptFilter

grails {
    plugin {
        jade {
            /* Additional filters for embedding different content types in a template, such as markdown, coffeescript */
            filters = ['coffeescript': new CoffeeScriptFilter()]
        }
    }
}

You can then use coffeescript in your jade.

somefile.jade
block content
    #bodytext Empty

    :coffeescript
        updateContent = -> document.getElementById('bodytext').innerHTML = 'Not Empty'

        do updateContent

Markdown Filter

To add filtering for markdown you would need to add markdownj to your path via lib or maven and add the following to your application.

BuildConfig.groovy
dependencies {
    compile('org.markdownj:markdownj:0.3.0-1.0.2b4')
    ...
}
Config.groovy
import de.neuland.jade4j.filter.MarkdownFilter

grails {
    plugin {
        jade {
            /* Additional filters for embedding different content types in a template, such as markdown, coffeescript */
            filters = ['markdown': new MarkdownFilter()]
        }
    }
}
somefile.jade
block content

    #bodytext
        :markdown
            ### Hello World ###

Multiple Filters

You can have multiple filters by simply adding them to the filter definition map.

Config.groovy
import de.neuland.jade4j.filter.CoffeeScriptFilter
import de.neuland.jade4j.filter.MarkdownFilter

grails {
    plugin {
        jade {
            /* Additional filters for embedding different content types in a template, such as markdown, coffeescript */
            filters = ['coffeescript': new CoffeeScriptFilter(), 'markdown': new MarkdownFilter()]
        }
    }
}

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.