Giter Site home page Giter Site logo

clay's Introduction

Clay

Build Status

An amazing prototyping tool.

http://lucuma.github.com/Clay

With Clay you can forget about making changes to dozens of HTML files just because you need to add a link in the footer.

You can also use it to prototype your AJAX-driven application or the responses of sending forms, because it acts like a real server.

Instructions

Run the development server with

$ clay run

or generate a static version of the site

$ clay build

Quickstart

$ clay new myappname

will generate a new app container with the following structure::

myappname
  ├── source/
  ├─────── static/
  ├── README.md
  └── settings.yml

Inside that folder, run the development server with:

$ clay run

and your site'll be available at http://localhost:8080/.

Anything you put under source will be render as a page. For instance source/page.html will be visible at http://localhost:8080/page.html, and source/foo/bar.json at http://localhost:8080/foo/bar.json.

To generate a static version of your site, stop the server (with Control + C) and run:

$ clay build

and all the templates will be processed and the result stored inside the build folder.

How to install

Just run

sudo pip install clay

and you're ready to go.

Templates

The real power of Clay comes by using the Jinja2 template syntax.

You can make a single file, (for instance, your header) and included it many times using:

{% include "header.html "%}

You can also use a powerful feature called template inheritance: inside the source folder you'll find a file called base.html. This is a page skeleton shared among the rest of HTML templates. You put in there anything you want to be repeated in every page, like the doctype declaration or maybe navigation links and a footer. You change something there and the rest of the pages will be automatically updated. Much more easy than manually search and replace a bunch of files!

The rest of the files, like index.html, are composed of blocks, like

{% block title %}Welcome to Clay{% endblock %}

Any content you put inside those blocks will be used to fill the same-named blocks in base.html. In this case to fill the <title> tag.

You can create new blocks for your templates. You can even create new base files, just change in your templates the base that they will use, by updating the line that says:

{% extends "base.html" %}

You can use more than just HTML: JSON, csv, plain text, etc. Any text-based format will be ok.

Jinja2 templates are much more than just template inheritance. For more advaced features check the [official documentation] (http://jinja.pocoo.org/docs/templates/).


Happy coding!


© [Lúcuma] (http://lucumalabs.com).
See AUTHORS.md for more details.
License: [MIT License] (http://www.opensource.org/licenses/mit-license.php).

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.