Strings are used to localize content. Content may be text, images or anything that pertains to
localizing the question. Strings are defined using the following syntax
Strings are pre-parsed. Before the HTML is added to DOM:
- String files are loaded.
- Slides are loaded.
- Hammer looks for and replaces the string tags with the string definitions.
- Hammer then adds the content to the display.
This means you could add practically anything you want into a string tag, but if you need to add complex HTML, you should instead use a mixin.
timer Exercise: Consuming strings
Though there are several string examples as a reference we are only going to look at out to create and consume a simple string.
Launch in your browser http://localhost:8080/sandbox/#/tutorials/strings/strings_start. It should open a page with "Custom Events Tutorial" displayed.
By default, strings files are located in the
strings directory. This can be changed in
Loading a string file
In your slide to use a string file, it must be loaded. To load a string file add the following line
<h:strings url="strings/global" />
url is relative to
If you open
sandbox/strings/global.xml, you will notice the root tag is defined as:
Hammer uses this information to know this file represents a strings XML file.
xmlns is required by Hammer. It is not declared will throw an error if it is
Note: You can declare any number of
in order to separate strings by structure, question, tasks, whatever works for you.
Defining a string tag
h:virtual, add the following line:
In your browser, refresh your page. You should now see "Hello, world!" appear on the page.
Be sure to check out the detailed set of examples for using strings in your exam.