os.inline()

Inline files.

Syntax

os.inline(f File) string os.inline(f File, wrap bool) string os.inline(f File, wrap bool, context File, request File, response File) string os.inline(col Collection) string os.inline(col Collection, wrap bool) string os.inline(col Collection, wrap bool, context File, request File, response File) string

Parameters

f File

The file to be inlined.

col Collection

A collection of files to be inlined, in provided order.

wrap bool

Wrap each file in unique div to make client-side tools make them responsive.

context File

Reference the context of the request - the page being visited. It defaults to the context file of the current transaction.

request File

The request file that holds all input data, typically provided by the HTTP request, but may be modified by the callee, particularly for testing purposes. It defaults to the request file of the current transaction.

response File

The response argument is a reference to the file that shall be decorated with response metadata like statusCode, location or the head string attribute. It defaults to the response file of the current transaction.

Description

Inline a file or collection via running their respective .Inline methods. All files to be inlined are run in separate isolated VMs.

When inlining a single file, its response body is returned. For collections, the merged response bodies for all files in the collection.

Note that after the response body is returned from the child transaction and before it is returned by this function, Boomla applies some post processing like namespacing CSS selectors and loading any Content-Security-Policy rules (from .Trust files).

The location and statusCode fields of the response body are also merged respecting the following rules:

  • For 3xx statusCodes, the location string attribute must be set.
  • If the location string attribute is set and the statusCode is left unchanged, the statusCode will default to 303.
  • A 5xx statusCode takes precedent over any statuscode < 500.
  • A 4xx statusCode takes precedent over any statuscode < 400.
  • A 3xx statusCode takes precedent over any statuscode < 300.
  • The statusCode 0 and 200 are equivalents.
  • If a statusCode is returned by a child transaction that falls within the same range (3xx, 4xx, 5xx) as already defined for the response file, that of the response file is not changed.

Examples

Simple example of child returning hello world. Note that the response is wrapped in a div so that client-side tools can make it responsive.

Simple example of child returning hello world, this time with all arguments specified.

Do not wrap child.

Child throws an error.

Pass on head tags. Note that the response file is passed to os.inline(), and so it is decorated with the head tags requested by the child. If you pass a different file instead of response, that file will be decorated instead.

Merge head tags for all child transactions.

If the child returns a status-code higher than that of the response file, the response file is updated.