An overview of all functions available in Fore.
As Fore uses XPath 3.1 as its expression language you also have access to the large library of functions that are defined by the standard.
Not 100% of the XPath 3.1 functions are available in fontoXPath. There are a few that might not be (fully) implemented. In doubt please refer to their github page or test in their wonderful fontoXPath playground.
In addition to XPath Fore defines some built-in functions that are essential for building fully event-driven user-interfaces.
base64encode(string)
This is probably the least used function but sometimes you need to base64-encode a string e.g. for sending it as a GET param.
Param:
string
- a string to be encodedReturns:
context(id)
The context()
function is needed in situations where several instance data sources are involved.
Param:
event(property)
The event
function is essential when working with events and params need to be passed. It allows to access properties
of the event details object which is passed in by the event dispatcher.
Param:
Returns:
event
is often used in conjunction withfx-dispatch
action which allows to set properties of a custom event.
fore-attr(attribute-name)
Returns the value of an attribute on the fx-fore
element in scope. Can be used to pass values to a Fore page loaded via
the src
attribute which in turn can use these values inside of its logic with the help of this function.
Param:
Returns:
index(id)
The index
function is used in combination with fx-repeat
elements. It returns the current index of a given repeat.
Param:
fx-repeat
elementReturns:
instance(id)
The instance
function is the most important function. It allows to address a certain fx-instance
element for data-binding.
Param:
fx-instance
element with given id. If not given it will default the first fx-instance
element in document orderReturns:
fx-instance
element. The type of the root context depends on the type of instance which can currently be ‘xml’ or ‘json’. For XML the root node of the instance data is returned. For JSON the outermost map or array will be returned.local-date()
Returns local date
Example output: 18/12)2023
local-dateTime()
Returns local dateTime
Example output: 18/12/2023, 17:01:56
log(id)
The log
function is just for development purposes and can be used to log some instance data to the document.
Param:
Returns:
Outputs it’s content to a <code>
block.
<code>{log('default')}</code>
uri()
Returns the full URI from the browser
Example output: http://localhost:8090/demo/uri.html?param1=value1¶m2=value2#hash
uri-fragment()
Returns the fragment of the current URI
Example output: #hash
uri-query()
Returns the query part of the URI
Example output: ?param1=value1¶m2=value2
uri-param(param-name)
Returns the value for URI param given by argument
Example output: value1
uri-path()
Returns the path part of the current URI
Example output: /demo/uri.html
uri-port()
Returns the port of the current URI
Example output: 8090
uri-scheme()
Returns the URI scheme of the current page
Example output: http:
uri-scheme-specific-part()
Returns the URI without the scheme-specific part
Example output: //localhost:8090/demo/uri.html?param1=value1¶m2=value2#hash