GithubHelp home page GithubHelp logo

toplevel's Introduction

TopLevel

TopLevel enables you to template your HTML, CSS, and Javascript at the Top Level like so:

<!doctype html>
<html>
  <head>
    <script src="YourBrowserCheckCode.js"></script>
    <script src="toplevel.js"></script>

    <!--% if ( CheckBrowser() == "broken" ) { -->
      <link rel="stylesheet" href="broken.css">
    <!--% } else { -->
      ...
    <!--% } -->
    ...

The stylesheet above will never load unless the branch is satisfied.

  • This Is Not a solution of injecting stuff after a page load.
  • This Is Not a solution of downloading and then removing things from the DOM.

The HTML code including the stylesheet will never be interpreted by the browser unless the function CheckBrowser() returns the string "broken". ... seriously ...


Another example:

<!doctype html>
<html>
  <head>
    <script src="toplevel.js"></script>
  </head>

  <body>

    <!--% for(var ix = 0; ix < 10; ix++) { -->
      <p><!--= ix --></p>
    <!--% } -->

  </body>

</html>

When you load the page in the browser you will see 10 paragraph blocks with numbers inside of them.

This Is A Total Game-Changer.

You can put TopLevel stanzas inside of CSS, HTML blocks, even HTML attributes. Take this for example:

<div id="header">
  <img src="logo_<!--= (isMobile() ? "50x50" : "200x200") -->.jpg">
</div>

Only one image will load - the right one for the browser.

There will be no broken looking "flash" --- the delivery is smooth and polished.

All Your JS Still Works.

  • $(document).ready
  • CSS selectors
  • Underscore
  • AMD Loaders, CoffeeScript, Knockout, Angular, Socket.io, Backbone, D3, yes --- all of them.

TopLevel is fast, transparent, and totally rewrites the rules of how you will create webpages.

Works Everywhere And Is 0.6 KB gzipped.

(1.2 KB minified and 4.4 KB for the development version)

It Works On:

  • Chrome
  • Firefox
  • Safari
  • IE
  • Opera
  • Dolphin
  • Seamonkey
  • Chromium

They're all in and all the features are there.

Proof? Ok, sure!

You're welcome.

Add this massive functionality in a single include with under a kilobyte of gzipped code.

Uses Underscore's Templating Engine

TopLevel takes its templating right from underscore. The functionality is identical with a slight change of syntax.

Template functions can both interpolate variables, using <!--= … -->, as well as execute arbitrary JavaScript code, with <!--% … -->. If you wish to interpolate a value, and have it be HTML-escaped, use <!--- … -->.

That is to say, a regular HTML comment block with the first character being either =, %, or -. Keep this in mind, and refer to the underscore documentation for further information!

Easily Enable TopLevel to Use Any Third-Party Library

Everything after the <script src="toplevel.js"></script> gets interpreted. If you want TopLevel to use a say, an MV* framework, simply include it before TopLevel, at the top of the HTML file like so:

<!doctype html>
<html>
  <head>
    ... dependencies you want to expose to TopLevel ...
    <script src="toplevel.js"></script>
    ...

License & Contributions

toplevel's People

Contributors

kristopolous avatar

Stargazers

Anne Thorpe avatar Ivan Levashev 卜根 avatar Michal Čaplygin avatar Toph Tucker avatar Kofi Gumbs avatar  avatar Jesse Talavera avatar D. Bohdan avatar Ivan Firsov avatar stagas avatar Ilya avatar Jonas Karg avatar Miguel Lorenzo avatar JMenkin avatar Stavros Skamagkis avatar  avatar Aseem Kishore avatar Travis Taylor avatar Carl V. Lewis avatar Ryan Khasky avatar Angus H. avatar Gordon Buhler avatar JFOC avatar  avatar Mana avatar Keanu Pang avatar Kersten Behrens avatar Leonid Koftun avatar Ramey Robles avatar Kleber Shimabuku avatar Volkan Unsal avatar Harry McIntyre avatar Ray Ch avatar Ali Halabyah avatar Jon Reece avatar M Haidar Hanif avatar  avatar Nikhil Krishna avatar Jason H. West avatar monk-blade avatar Dmitriy Plekhanov avatar  avatar real deprez avatar Pierre Gouthéraud avatar Mark Jayson Fuentes avatar Rob Eberhardt avatar  avatar Romain Dardour avatar Luiz Boaretto avatar 張旭 avatar 文宇祥 avatar Rich Lee avatar Marko avatar Craig Keeling avatar Manuel Pineyro avatar Cem K. avatar Jonathan Barratt avatar Andy Axton avatar Jeff Triplett avatar Miikka avatar Brandon Brown avatar AJ avatar Richard Littauer avatar Edmundas Mišeikis avatar Loïc Mahieu avatar Rozario Chivers avatar Brandon Anzaldi avatar Philipp Muens avatar Tomáš Králík avatar hiroyuki ogawa avatar Paul Osborne avatar  avatar Gio d'Amelio avatar Markus Kohlhase avatar Andrew Sullivan avatar Hitesh Trivedi avatar Jodoo Shi avatar Dan Haber avatar C. Anglin avatar Nick Sweeting avatar Huy Nguyen Quang avatar Yuya Saito avatar John Henry avatar  avatar Bin Wang avatar Eleftherios Kosmas avatar ForeverScape avatar nick avatar  avatar Mukunda Modell avatar Jan Bretschneider avatar David Bass avatar Varun Malhotra avatar Jarin Udom avatar André Ruffert avatar Jeff Carroll avatar Raghu Ram Bongula avatar Simon Hamp avatar Felipe Coury avatar mark prokoudine avatar

Watchers

Rozario Chivers avatar SeeVa avatar ForeverScape avatar evandrix avatar  avatar Tomáš Králík avatar James Cloos avatar SW LLC avatar Mladen Yakimov avatar Stavros Skamagkis avatar  avatar Jonas Karg avatar  avatar

toplevel's Issues

Connecting...

Firefox shows "Connecting..." in the title bar and the spinner. It never goes away. This doesn't happen in Chrome.

Blink - mobile flakey

It sometimes works. No error, nothing in console log. There's something timing something something up...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.