Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Markup and Style without HTML and CSS

Jed Schmidt
November 29, 2012

Markup and Style without HTML and CSS

Presented at jscamp.asia.

Jed Schmidt

November 29, 2012
Tweet

More Decks by Jed Schmidt

Other Decks in Programming

Transcript

  1. 2004: JA 2005: JA 2006: JA 2007: JA 2008: JA

    2009: JA 2010: JA 2011: JA 2012: JA ✘JS
  2. 1. Browser connects to server 2. Server gives browser a

    hostname 3. Server proxies HTTP in 4. Server proxies HTTP out 5. Browser becomes a server
  3. uritemplate An UriTemplate implementation of rfc 6570 url-template utc Simple

    underscore.js template compiler. utml Express compliant templating for underscore.js vacuum Clean streamed templates (primarily for HTML) vash Razor syntax templates, for JS velocity.js Velocity Template Language(VTL) for JavaScript vie Editable RDFa with Backbone.js and JSON-LD view-test view-test allows you to easily test Jade and EJS templates views Views registry and rendering walrus A bolder kind of mustache. web2splash A PhoneGap splash screen generator using an HTML document weber A tool for compiling scripts, stylesheets and templates wh webfiller Webfiller puts data and styling into Web pages on the serv webhook-templates Dust.js templates for webhook payloads weld Template antimatter for javascript wings Templating library that works on the server and client clo wintersmith-nunjucks Nunjucks templates for Wintersmith woot Quickly create new projects based on custom templates xjs A templating language for node.js using xml and javascript xjst XSLT inspired JavaScript templates (with spices) xmlb XML builder templates for Node.js. xsl2yate converts xsl templates to yate yajet Template engine forked from http://www.yajet.net/ yate Yet Another Template Engine yatl JSON-based template engine yhandlebars Command line tool to precompile Handlebars templates as YU yui3boiler simple utility to initialize module source directory struc zappajs-template A working ZappaJS server with useful templates zeke a plug-able coffeescript template generator
  4. <script type="text/not-js"> Hello {{name}} You have just won ${{value}}! {{#in_ca}}

    Well, ${{taxed_value}}, after taxes. {{/in_ca}} </script>
  5. A ABBR ACRONYM ADDRESS AREA ARTICLE ASIDE AUDIO B BDI

    BDO BIG BLOCKQUOTE BODY BR BUTTON CANVAS CAPTION CITE CODE COL COLGROUP COMMAND DATALIST DD DEL DETAILS DFN DIV DL DT EM EMBED FIELDSET FIGCAPTION FIGURE FOOTER FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HEADER HGROUP HR HTML I IFRAME IMG INPUT INS KBD KEYGEN LABEL LEGEND LI LINK MAP MARK META METER NAV NOSCRIPT OBJECT OL OPTGROUP OPTION OUTPUT P PARAM PRE PROGRESS Q RP RT RUBY SAMP SCRIPT SECTION SELECT SMALL SOURCE SPAN SPLIT STRONG STYLE SUB SUMMARY SUP TABLE TBODY TD TEXTAREA TFOOT TH THEAD TIME TITLE TR TRACK TT UL VAR VIDEO WBR
  6. CSS

  7. var styleSheet = STYLE({type: "text/css"}, STYLE.on("a", {color: "red"}), STYLE.on("*", {margin:

    0, padding: 0}) ) alert(styleSheet.innerHTML == "a{color:red;}\n*{margin:0;padding:0;}\n")
  8. var blue = "#3B5998" var gray = "#3B3B3B" var defaultRadius

    = 10 function roundedCorners(radius) { return { borderRadius : radius, WebkitBorderRadius : radius, MozBorderRadius : radius } } var styleSheet = STYLE({type: "text/css"}, STYLE.on("h2", {color: gray}, roundedCorners(defaultRadius)), STYLE.on("h1", {color: blue}, roundedCorners(defaultRadius * 2)) )
  9. var nestedStyles = STYLE({type: "text/css"}, STYLE.on("a", {color: "red"}, STYLE.on("img", {borderWidth:

    0}) ) ) var normalStyles = STYLE({type: "text/css"}, STYLE.on("a", {color: "red"}), STYLE.on("a img", {borderWidth: 0}) ) alert(nestedStyles.innerHTML == normalStyles.innerHTML)
  10. so.

  11. If we are willing to let go of the surface

    syntax of HTML and CSS...
  12. 1. Reduce our exposure to XSS attacks 2. Eliminate a

    separate compile step 3. Write our DOM code where it makes sense 4. Use JavaScript syntax everywhere 5. Decouple our syntax sugar 6. Reduce the number of moving parts 7. Reuse existing infrastructure 8. Lessen the burden of context switching