/jsonml-libsonnet

Jsonnet library to generate XML/HTML.

Primary LanguageJsonnetApache License 2.0Apache-2.0

jsonml-libsonnet

Jsonnet library to generate XML/HTML.

Install

jb install github.com/Duologic/jsonml-libsonnet@main

Usage

local ml = import 'github.com/Duologic/jsonml-libsonnet/main.libsonnet';

local head = ml.tag.new('head');

local body =
  ml.tag.new('body')
  + ml.tag.withElements(
    ml.tag.new('h1')
    + ml.tag.withElements(
      ml.literal.new('title')
    )
  );

local html =
  ml.tag.new('html')
  + ml.tag.withAttributes(
    ml.attribute.new('lang', 'en')
  )
  + ml.tag.withElements([
    head,
    body,
  ]);


html.manifest()

Index

Fields

obj attribute

fn attribute.new

attribute.new(name, value)

PARAMETERS:

  • name (string)
  • value (boolean,null,number,string)

fn attribute.withName

attribute.withName(value)

PARAMETERS:

  • value (string)

fn attribute.withType

attribute.withType()

fn attribute.withValue

attribute.withValue(value)

PARAMETERS:

  • value (boolean,null,number,string)

obj literal

fn literal.new

literal.new(value)

PARAMETERS:

  • value (string)

fn literal.withType

literal.withType()

fn literal.withValue

literal.withValue(value)

PARAMETERS:

  • value (string)

obj tag

fn tag.new

tag.new(name)

PARAMETERS:

  • name (string)

fn tag.withAttributes

tag.withAttributes(value)

PARAMETERS:

  • value (array)

fn tag.withAttributesMixin

tag.withAttributesMixin(value)

PARAMETERS:

  • value (array)

fn tag.withElements

tag.withElements(value)

PARAMETERS:

  • value (array)

fn tag.withElementsMixin

tag.withElementsMixin(value)

PARAMETERS:

  • value (array)

fn tag.withName

tag.withName(value)

PARAMETERS:

  • value (string)

fn tag.withType

tag.withType()