Coder Social home page Coder Social logo

meryl's Introduction

Meryl

Meryl is a minimalist web framework for nodejs platform. It is really simple to use, fun to play and easy to modify.

It consists of only ~240 source lines of code. Here is the proof.

$ uglifyjs -b -nm --no-seqs -ns -nc meryl.js | wc -l
     233

Install

Use node package manager 'npm' to install latest Meryl version.

npm install meryl

Usage

Here is simple preview.

// take the pills
var meryl = require('meryl');

// first, take it easy
meryl.get('/', function (req, resp) {
	resp.end('<h3>Hello, World!</h3>');
});

// not impressed? let it interfere with blood some more
meryl.get('/greet/{who}', function(req, resp) {
	resp.render('greeter_template', {name: req.params.who});
});

// lay down and enjoy it
meryl.plug('GET *', function(req, resp, next) {
	resp.setHeader('server', 'meryl');
	next();
});
 
// now you are a 'meryl' junkie
meryl.run();

Meryl is Connect middleware compatible. Serve static content in seconds.

meryl
  .plug('GET *',
    connect.favicon(),
    connect.static(".")
  )
  .get('/', function (req, resp) {
    resp.end("<h1>Welcome To NodeJS!</h1><img src='nodejs.png' />");
  })
  .run();

Love (fab)? Checkout (fab) flavored meryl.

with (connect) {
  meryl
    .fabby
      (logger(), static("."))
      ('GET /', function (req, resp) {
          resp.render('home');
        }
      )
      ('GET /posts/{postid}', function (req, resp) {
          resp.render('home');
        }
      )
      ('GET /posts/{postid}/comments/{commentid}', function (req, resp) {
          resp.render('home');
        }
      )
      ();
}

Also taste meryl with coffeescript, using coffeekup

people = ['animal', 'beakers', 'piggy', 'kermit']

meryl

  .plug connect.logger(),
    connect.static(".")

  .get '/', (req, resp) ->
    resp.redirect('/people')

  .get '/people', (req, resp) ->
    resp.render 'layout',
      content: 'list'
      context:
        people: people

  .get '/people/{personid}', (req, resp) ->
    resp.render 'layout',
      content: 'show'
      context:
        person: people[req.params.personid]

  .run
    templateExt: '.coffee'
    templateFunc: coffeekup.adapters.meryl

You can of course use its cgi interface.

require('http').createServer(
  meryl
    .get('/', function (req, resp) {
      resp.end("<h1>Demonstraing Meryl</h1>");
    })
    .cgi()
).listen(3000);

Meryl has much more, please continue from the links below.

Please visit wiki page for documentation: http://github.com/kadirpekel/meryl/wiki

Also there are plenty of examples in 'examples' directory: http://github.com/kadirpekel/meryl/tree/master/examples

For updates please follow: http://twitter.com/meryljs

Contributors:

meryl's People

Contributors

kadirpekel avatar siebertm avatar stagas avatar

Watchers

James Cloos avatar

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.