1. Mark Lang
  2. Biscuit

Wiki

Clone wiki

Biscuit / Home

Welcome

Welcome to biscuit 0.1 codename "cookie".

Users of RML

This section details how to carry out the actions of rml within biscuit. Unlike rml which uses tags Biscuit using attributes which can be applied to any html element in a document. This means these attributes can be applied to almost anything div's, span's, header tags - almost any element can contain a Biscuit attribute. Futhermore multiple Biscuit attributes can be appiled to one html element.

variables

Hello <span bml-global-var='hello'></span>

This will simply insert the value of the variable "hello" as the contents of the span tags. Other variable attributes exists for displaying class properties, array values, post, cookie, session and querystring strings.

If you want to do inline variables or include a variable within another bml-attribute simply enclose the variable in braces e.g {hello}. This is shown in the trigger example below.

Switch

A switch can be done using the biscuit attribute of "bml-trigger". Trigger unlike switch isn't just a boolean checker, but it's a fully featured if statement.

<div id='admin_links' bml-trigger='{is_admin}|==|true'>
<a href=''>Admin Panel</a>
</div>

This simply checks to see if the is_admin variable is equal to true, if so the contains of the div are displayed. For else switches simply use "!=" instead of "==".

Blocks

Simple looping is supported, but in the next release looping will be fully supported with features to allow odd and even row push outs. futhermore you will be able to set the number of loops and the index to start from. An example of a simple loop is below:

<div id='user_details' bml-loop='users'>
<span bml-loop-var='id'></span>
</div>

Inheritance Templates

Templates can be inherited using the bml-editable attribute as shown below.

Parent Page:

<div id='main_content' bml-editable='true'>
hello child
</div>

Child Page:

<div id='main_content'>
hello parent i'm the child
</div>

Simply attach the bml-editable equals true to the element within parent page you want to use as a editable content region. Then simply have a element with the same id within the child page and the content will be automatically inherited from the child, easy as that.

New features not in RML

Syntax wise attributes can be nested and embedded more easily than in rml. Attributes can use either single or double quotes, unlike rml element which must use single quotes only. The Parser of Biscuit can easily be expanned and custom attributes created by the user simply by created a element class in the elements folder.

Functions

Biscuit allows the user to execute a function, which the user has defined and return the output. Fuctions are defined as variables as func_functionname => phpfunctionname

example:

<div id='hello_world_wc' bml-function='str_word_count("hello world")'>
</div>

Class Properties

Biscuit allows a user to display the value of a property of a class, making it easier to manage variables.

Example:

<h3>My User id is: <span id='user_id' bml-class-property='user.userid'></span></h3>

This will display the property id of the class user, within the span tag "user_id".

Arrays

Biscuit allows the user to display a value of an element within an array

<div bml-array-var='users[1].id'>
</div>

This will display the id of the second user within the array, as the contents of the div.

Variable Defines

Biscuit allows the user to define variables within a template, this is good for combining variables and litterals that are commonly used.

example:

<div bml-define-var='foo|bar'></div>
<span bml-global-var='foo'></span>

In the example above we define a variable called "foo" with the value "bar". Then we display the contents of "foo" within the span tag and thus "bar" will be outputted.

Bind Variables to Attributes

Example:

<a href='' bml-attribute-bind='href|{test}'>test</a>

This will bind the value of variable test to the attribute href of the a element. If you don't want to replace the attribute but append to it, you can instead use the attribute bml-attribute-append.

Removed from RML

  • RCSS - The rml css parser has been removed, but may be developed in a later release or a component of the wafer framework.
  • Custom Element tags - The abltiy to parse an element as another e.g "<nav>" becomes "<div id='nav'>" this has been removed since Biscuit doesn't deal with elements.
  • Automatic Doctype Insertion - This may be included in the next release, but since Biscuit recommands using vaild code and HTML5 Biscuit automatically adds a html5 doctype to the document.
  • Caching - This should be hopefully be implemented in the next release.
  • Backwards Compatabltiy - There is no backwards. compatablity between Biscuit and RML, although a converter is being worked on to resolve this problem.

Can I use RML and BML????

Yes you can both rml and bml together if you wish, but note how you manage the rendering of content and the managing of variables between each of the template engines will be down to your own discretion, no function is built into Biscuit to allow this.

Updated