Advanced Usage

Table of Contents

Builder and Parser

You can achieve the same thing that was achieved with Rockplate class on Getting Started section, but with more control with Builder and Parser classes.

Schema

Schema can be passed as an object (recommended) or embedded into template (recommended only in standalone .rpl and .rphtml files)

Async schema

When working with .rpl and .rphtml files, you can have your schema in an external json file, you should reference that json file from your rpl file by defining a json object on top of the file with only a key named "schema" with the json file path relative to the rpl file.

my-schema.json file

my-template.rpl file

As seen on Getting Started section, you can pass a synchronous schema resolver function, or you can pass an asynchronous schema resolver with promises.

Strict mode

Strict mode is enabled automatically when you pass schema while creating Builder, Linter or Rockplate instance. You can override this setting via the third parameter.

Linter

When working with standalone .rpl and .rphtml files, Linter can be created with schema (strict mode) and params can be omitted when linting.

Meanwhile, Linter can be created without schema (non strict mode) and params can be passed for linting on the fly.

When you do not want the linter to resolve the lines the errors occured, set the second argument of lint() method to false


Made with ❤️ from Safraz Razik