sjs-4et

Embedded JavaScript engine, like sjs-4e with integrated Turbo CSS support.

sjs-4et

Embedded JavaScript engine, a dialect of sjs-4 that is similar to PHP, with integrated Turbo CSS support.

Description

Embed JavaScript code into HTML similar to PHP, with integrated Turbo CSS support. The code will be transpiled to sjs-4 before being executed, thus you can use the API of the sjs-4 engine.

Source mapping is not implemented yet. When an error is encountered, the row will be reported correctly, while the column (char position) will be incorrect.

Syntax

There are only a couple of syntax elements to be aware of:

  • Embed JS code: <? ... ?>,
  • escape and print the value of foo: <?= foo ?>,
  • print the value of foo (unescaped raw html): <?== foo ?>,
  • print to the output buffer within JS code blocks: print().
  • HTML class attributes that contain no JS code are automatically passed through a Turbo CSS compiler instance

Examples

Write HTML escaped output to the output buffer.

Write raw unescaped output to the output buffer.

Comment.

Embed JS for control flow, no output.

You can call print() to write to the output buffer.

Closing tag is optional.

Empty code block is fine.

Printing <? and ?>.

The line number is reported correctly, the column number incorrectly.

Spaces must be used between <? and the comment block.

Use Turbo CSS to style elements.

Import and use a Turbo CSS library.

Feed the Turbo CSS compiler from JavaScript.

Feed the Turbo CSS compiler via the t1() shorthand method from JavaScript, so that the “t1” prefix is not required.

Mix Turbo CSS classes with other classes on the same element by separating them with a semicolon (;).