Xbasic

a5_merge_json_into_template Function

Syntax

C Result = a5_merge_JSON_into_template(jsonData as C, template as C [, javascriptFunctions as C [, partialTemplatesJSON as C [, localCSS as C ]]])

Arguments

jsonDataCharacter

The JSON data to merge into a template.

templateCharacter

The template, defined using Client-side Template syntax.

javascriptFunctionsCharacter

Javascript functions referenced by the template.

partialTemplatesJSONCharacter

Defines partial templates that are referenced in the template.

localCSSCharacter

Local CSS definitions used in the template.

Description

The a5_merge_JSON_into_template function merges JSON data into a client-side template.

Discussion

The a5_merge_JSON_into_template function can be used to merge JSON data in to a template. The template is defined using Client-side Templates. The optional parameters allow you to define any Javascript functions, partial templates, or CSS styles that are referenced or used by the template. The function returns the generated HTML to be returned to the client web browser.

Example

dim data as c 
data = <<%txt%
{firstname: 'Fred', lastname: 'Jones'}
%txt%

template = <<%html%
Name: {firstname} {lastname}
%html%

htmlOut = a5_merge_JSON_into_template(data,template)

showvar(htmlOut)

See Also