The usual work for developers is taken care of.
There are no new syntax rules or languages to learn. Although simple and small, it handles multi-site, inheritance, templating, mobile & platform-specifics, and multi-user fileserving.
Using Meta-OS, you can provide visitors with instantaneous navigation and a native app feel, all in a tiny footprint.
There are 4 main folders in the distro.
config.json contains oft-changed global variables, globeVar and shareVar being also available to the client.
HTML5 was designed to be extensible, and is widely understood. TiTe overloads it for component creation, templating shortcuts and also to supercharge widgets.
Traditionally, server-side templating was used to insert variables and iterators, and it includes logic:
and client-side methods were used to progressively enchance elements:
Instead of combining the two methods, JSX takes templates away from HTML-only coders and forces them to learn a hybrid scripting language.
Angular stamps its ugly "ng" tags over templates instead of extending HTML, and encourages the use of three more hybrid scripting languages.
Neither of them are useable on the client!
TiTe is smarter:
Tags like <doctype> and <meta> are taken care of by html/shell.html
Homepage <html> attributes become site-wide accessible constants. Special attributes include noscript (render server-side for noscript users), tmpl_require (load additional JS modules), tmpl_style_buts (set page theme), tmpl_style_back (set page background),inherit (override inheritance)
Headers, sidebars and footers are automatically inherited from parent folders.
Certain shortcuts are available
<SCRIPT> and <STYLE> can be placed in templates without concern - they are magically extracted, combined, minified and served in the right order.
The overloaded <tt> tag allows for unbeatable UI flexibility...
Extending HTML5 with TiTe
Certain tags are extracted or transformed into standard HTML.
<TOP> is where the navigation goes.
<SIDE> is where sidebar (desktop) or additional (mobile) content goes.
<MAIN> is for the main page content.
<BOT> contains the footer.
<STYLE> is where CSS specific to the page goes - but it will go into the global stylesheet.
*NB* this MUST be UPPERCASE (so that one can, if needed, add scripts to a template which are not extracted, by using lowercase)
Super Tags ▼
<tt> is used for buttons, sliders, dropdowns, textareas and other widgets.
<rollup> is a universal implementation of HTML5's <details> & <summary> tags. Thou activated a rollup in order to read these words!
<list> is a way of going through an object or array.
<group> injects its properties into child buttons.
If a className contains "vardim", these attributes determine that element's dimensions:
weq (width), heq (height), xeq (left), yeq (top), ceq (className) eg:
To eliminate labourious recoding of UI elements and attaching events, <tt> is used. Here's the code for the button below:
<tt> buttons can have the following attributes:
sliders can also have attributes min, max links - <a href> for buttons
help - verbose explanation of button's function too big to go next to button (displayed as notification or popup)
on (no value required) - indicate a button is on
group - for related buttons
label - adds a label above the button
options - for radios, dropdowns etc: list of options
labels - for radios, dropdowns etc: list of labels
key - keyboard shortcut for button
(hard), target - the variable to sync with this button's value (hard attribute saves to localStorage also)
sigil - use canvas vectorgraphic instead of text
The id attribute you know and love; rollup makes it target the ru_tt rollup, and genus is set to make the button behave like a checkbox.
The templater uses tite.but to transform tt tags into standard HTML.
Button states are not stored in data-whatever attributes; instead they live in window.opz
why opz? ▼
Apps are made of ops, and opz are easier to grep than ops. opz are not always buttons, but buttons are always opz.
You did click on the question...
There's a lot more going on - examine browser/tite/buts.js
Global libraries are inside three folders:
source/browser/ source/common/ source/server/
source/common/bios.js is the first lib loaded by both server and client. It contains many methods used throughout the codebase.
server.js is the node.js server and lives in the main folder with config.json.
To run code just on a specific page, add that <SCRIPT> to the template. It will run after the rest of the page (and associated code) has initialized. It works with pushState too :)
Add site-wide code inside <SCRIPT scope="sitewide"> tags. This will run before page-specific code.
Scripts that outgrow their templates should be moved into source/
In package.json, be aware that enabling SQUISH may introduce errors, because uglify-js is imperfect.
Add to sitewide CSS by adding <STYLE> tags to any page.
If a page is deleted, CSS specific to it will be deleted too, so there will be no orphan CSS on the site.
Prefixes & Minifying ▼
Browser prefixes like -moz- and -webkit- are added automatically.
Ditto with alternative rule names for eg. display:flex - just use the W3C syntax in your code.
You can prepend CSS selectors to all rules within blocks - eg. <STYLE prefix=".super-class">.
Mark CSS to be minified by giving it an ID - eg. <STYLE id="MinMe">.
Since all CSS is loaded together, you can instantly see if you have CSS conflicts that would normally go undetected.
Add a css.html template containing a suite of the elements the site uses to test all the CSS in one place.
The STYLE tags in this file will be extracted and added to the global CSS, but the HTML will not be visible in production environments.
The same APIs can run in 3 scenarios:
█ before server-side rendering.
█ before client-side rendering.
█ on the client, as an update.
2 arguments are passed: the object to populate and a callback function. eg:
Clever use of closures means the callback function is aware of the sob object and does not need it passed.
As in the previous example, per-request server objects keep most of their properties private and only pass public vars objects to templates.
Ensure a page has API-supplied vars for template rendering, clientside OR serverside, by adding an attribute to the HTML element:
To save CPU, server-side rendering starts off disabled. You should enable it for all searchable pages by adding a noscript attribute to the HTML element.
server.js + source/server/clerk.js form the bulk of the server.
To simplify bouncing objects around callbacks, eg:
req and res are not usually passed as separate arguments. A single temporary per-request object is used, with ask (req) and give (res) properties.
Other useful properties of this object include:
vars - variables to be passed to the templater
file - the filename of the response, used to determine Content-Type, and ensure downloadable files are sensibly named.
mysite - the master domain name.
mod - the Last-Modified date.
Files in the media folder are split by type into subfolders.
Images go in the Image subfolder, fonts in the Font subfolder etc.
Unrecognized files go in the Mixed subfolder.
These subfolders need not form part of the URL.
So the server will look for <a href="/media/icon.png">img</a> inside the media/Image folder.