Rather than re-implement websites in more popular languages, like Perl or PHP, a small group of SMX fans decided to re-implement the language itself as an Apache module.
SMX was designed to embed macros in HTML/XML pages.
A good example of a macro is %counter(). This embeds a simple incremental counter on an HTML page. To include the results of a SQL query on a page, you can simply type %sql(<dsn>,<query>,%col(1)<br />) in the middle of an XHTML page.
Owing to the high-level nature of the language, SMX can greatly reduce the programming effort required to build dynamic or database-driven web sites.
Arguments can be quoted using double-quotes. Backslashes can be used to escape commas and double-quotes. A single quote at the beginning of an argument turns off interpretation of code in that argument (similar to LISP).
Everything that isn't code, is, by default, output. To change this behavior, use the %nil or %null macros.
%expand% Hello World!
Using variables to create output
%expand% %set(name,World) Hello %name%!
%expand%
%if(%form(expr)
,Result is: %expr(%form(expr))
)
%expand% %counter(hits) hits
%expand%
%if(%not(%exists(/tmp/gbook.sq3))
,%sql(sqlite:/tmp/gbook.sq3,create table guests (name text, comment text))
)
%if(%and(%form(name),%form(comment))
,%sql(sqlite:/tmp/gbook.sq3,"insert into guests (name, comment) values (%sqlq(%form(name)),%sqlq(%form(comment)))")
)
%sql(sqlite:/tmp/gbook.sq3,select * from guests
,%html-quote