3.21 library(http/js_write): Utilities for including JavaScript
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • SWI-Prolog HTTP support
        • The HTTP server libraries
          • library(http/js_write): Utilities for including JavaScript
            • js_script//1
            • javascript/4
            • js_call//1
            • js_new//2
            • js_arg_list//1
            • js_expression//1
            • js_arg//1
Availability::- use_module(library(http/js_write)).
Source[det]js_expression(+Expression)//
Emit a single JSON argument. Expression is one of:
Variable
Emitted as Javascript null
List
Produces a Javascript list, where each element is processed by this library.
object(Attributes)
Where Attributes is a Key-Value list where each pair can be written as Key-Value, Key=Value or Key(Value), accomodating all common constructs for this used in Prolog. $ { K:V, ... } Same as object(Attributes), providing a more JavaScript-like syntax. This may be useful if the object appears literally in the source-code, but is generally less friendlyto produce as a result from a computation.
Dict
Emit a dict as a JSON object using json_write_dict/3.
json(Term)
Emits a term using json_write/3.
@(Atom)
Emits these constants without quotes. Normally used for the symbols true, false and null, but can also be use for emitting JavaScript symbols (i.e. function- or variable names).
Number
Emited literally
symbol(Atom)
Synonym for @(Atom). Deprecated.
Atom or String
Emitted as quoted JavaScript string.