home
features
quick start
download
documentation
thymol files
configuration
message resources
control parameters
expression objects
thymol types
thymol API
thymol extensions
examples
sessions
say-hello
stsm example
with-dialect
extrathyme
petclinic
news
credits
user forum
issues
browser constraints
other known issues
create new issue
thymeleaf

thymoljs

configuration

setting up

Before using Thymol, you will need to configure the bootstrap loader file. You do this by setting values in the thymolConfiguration object in "thymol.js":

        var thymolConfiguration = {
        // Please set the values of the following fields!
            thScriptName : "${thThymolSource}",
            thJQuerySource : "${thJQuerySource}",
        // These are defaults, change them if you wish..
            thDefaultPrefix : "th",
            thDefaultDataPrefix : "data",
            thDefaultPrecision : 10,
            thDefaultProtocol : "file:///",
            thDefaultLocale : "en",
            thDefaultPrecedence : 20000,
            thDefaultMessagePath : "",
            thDefaultResourcePath : "",
            thDefaultMessagesBaseName : "Messages",
            thDefaultRelativeRootPath: "",
            thDefaultExtendedMapping: false,
            thDefaultLocalMessages : true,
            thDefaultDisableMessages : false,
            thDefaultTemplateSuffix : ".html"
        };

You must edit the value assigned to the "thScriptName" field and set it's value to the name of the Thymol library that you wish to use ("thymol-full.js" or "thymol-lite.js" or the minified version of either).

The "thJQuerySource" field allows you to define the location of the jquery library you wish to use with Thymol. By default, the jquery library is assumed to be present in the same directory as your Thmyol library file (as specified by "thScriptName"), if this is the case, you only need to provide the jquery file name to get things working.

If you remove the "thJQuerySource" field or set it's value to null or blank, then the bootstrap won't try to load jquery at all - use this option if your templates load jquery for themselves (via "<script>" tags or otherwise).

To use a network available copy of jquery then set the value of "thJQuerySource" to an appropriate URI.

invocation

Having correctly configured "thymol.js" you may now use it in your templates like this:

       <script type="text/javascript" 
         src="<path-to-installed-file>/thymol.js" 
         data-thymol-load="<list-of-project-specific-files>" 
         data-thymol-parameters="<parameter-string>">
       </script>

The "thymol.js" script may be used to load any number of additional script files specified by a comma separated list value for the "data-thymol-load" attribute. The path to each file in the list is assumed to be relative to the path given in the "src" attribute.

You may also pass command-line parameters to Thymol by using the "data-thymol-parameters" attribute. This should be specified as a standard request parameter string (a name/value pair list starting with a "?" and separated by "&").

If you wish to override the usual mechanism of locating jquery for a particular template you can do this by specifying the "data-jquery-src" attribute in the bootloader script tag.

For example:

       <script type="text/javascript" 
         src="web/js/thymol.js" 
         data-jquery-src="http://code.jquery.com/jquery-git2.min.js"
         data-thymol-load="page-data.js" 
         data-thymol-parameters="?thDebug=true">
       </script>

default values

The configuration default values defined in thymol.js specify the reference value that will be used by Thymol for a particular operation should no overriding value be specified for a particular template.

For example, setting the value of "thDefaultTemplateSuffix" to ".thtml", would cause Thymol to use the file extension ".thtml" when searching for templates, unless this value was overridden by setting a value for thTemplateSuffix in a template directly using one of the usual mechanisms (see).

thDefaultPrefix

Sets the default value to be used as the prefix for Thymol processable attributes.

thDefaultDataPrefix

Sets the default value to be used as the prefix representing html5-style Thymol attributes.

thDefaultProtocol

Sets the value to be used as the protocol part of generated URIs in the (unlikely) event that this cannot be derived from the DOM and hasn't been specified by thProtocol.

thDefaultLocale

Sets the value to be used as the locale value if this has not been specified by setting thLocale and cannot be deduced from the browser's navigator object.

thDefaultResourcePath

Sets the default value for the relative path to be used to locate resource files.

thDefaultMessagePath

Sets the default value for the path to be used to locate message properties files.

thDefaultMessagesBaseName

Sets the default value for the base file name to be used when searching for message properties files.

thDefaultRelativeRootPath

Sets the default value for the thRelativeRootPath variable.

thDefaultExtendedMapping

Sets the default value for the thExtendedMapping variable.

thDefaultLocalMessages

Sets the default value for the thLocalMessages variable.

thDefaultDisableMessages

Sets the default value for the thDisableMessages variable.

thDefaultTemplateSuffix

Sets the default value for the thTemplateSuffix variable.

default dynamic values

There are two more configuration values that need to be assigned default values, these are the numeric precision control parameter and the attribute processing precedence values. They are included in this section because they must be given values and hence they are set in the "thymol.js" script.

thDefaultPrecedence

Sets the default value to be used for processing precedence when defining custom attribute processors.

thDefaultPrecision

Sets the default value for the number of significant decimal digits to be used in floating point calculations in Thymol.