slime 0.3.0

handlebars and toml based simple and flexible static page generator library
docs.rs failed to build slime-0.3.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: slime-0.4.0

Slime

Build Status Latest Version

Handlebars based flexible static site generator library

Why slime

Because it is slim(e) and flexible (like a slime...)

What?

template + data = static page!

How

  • handlebars
  • toml/json
  • few simple helpers

Why?

  • more flexible design - can reuse/manipulate data by merging or modyfing loaded json
  • modular - support for partial templates
  • easy to learn - using already popular json and handlebars combination
  • easy to start - copy example and edit json/handlebar files to create one static page without touching rust code

Installation

Create new binary crate. Run:

curl -s https://raw.githubusercontent.com/jaroslaw-weber/slime/master/init_slime.sh | bash

(setup folders and deploy scripts for github+travis)

Show me

Folder structure:

- generated (generated html files)
- data (data to insert into templates)
 - index.toml
- templates
 - index.hbs (handlebar templates)
deploy.sh (deploying generated html files to github pages)
.travis.yml (travis build script)

Code:

extern crate slime;
use slime::Slime;

fn main() {
    //create new wrapper
    let s = Slime::default();

    //load data
    let data1 = s.load_json_data("data1").expect("failed to load json data");
    let data2 = s.load_toml_data("data2").expect("failed to load toml data");

    //generate html files
    s.generate("index", "json_version", &data1)
        .expect("failed to generate page with json data");
    s.generate("index", "toml_version", &data2)
        .expect("failed to generate page with toml data");
}

So what is going on?

let mut s = Slime::default();

Create new wrapper.

let data1 = s.load_json_data("data1").expect("failed to load json data");
let data2 = s.load_toml_data("data2").expect("failed to load toml data");

Load some toml/json data from data folder.

s.generate("index", "json_version", &data1)
    .expect("failed to generate page with json data");
s.generate("index", "toml_version", &data2)
    .expect("failed to generate page with toml data");

Generate html files.

New features

  • installation script
  • reading toml files
  • simpler api
  • toml format

So what next?

  • slime binary mode (using slime library without writing rust code)
  • improve api
  • improve error messages (use failure crate)
  • example how to create nice websites with css frameworks
  • add tests
  • write tutorial
  • add links to projects using slime to README file
  • add more examples
  • add toml -> json conversion
  • improve installation script

Binary mode

Generating page without writing rust code. (todo: not implemented yet)

Install slime with

cargo install slime

Initialize project with

cargo slime --init

Put data in data folder. Put templates in template folder. Push everything to github. Setup travis and wait for build to finish. Your website will be generated and deployed automatically!