Quasi quotation parser for JavaScript that allows for embedding Prolog
variables to substitude identifiers in the JavaScript snippet.
Parameterizing a JavaScript string is achieved using the JavaScript +
operator, which results in concatenation at the client side.
...,
js_script({|javascript(Id, Config)||
$(document).ready(function() {
$("#"+Id).tagit(Config);
});
|}),
...
The current implementation tokenizes the JavaScript input and yields
syntax errors on unterminated comments, strings, etc. No further parsing
is implemented, which makes it possible to produce syntactically
incorrect and partial JavaScript. Future versions are likely to include
a full parser, generating syntax errors.
The parser produces a term \List
, which is suitable for
js_script//1 and html//1.
Embedded variables are mapped to
\js_expression(Var)
, while the remaining text is mapped to
atoms.
- To be done
- Implement a full JavaScript parser. Users should not rely on the
ability to generate partial JavaScript snippets.