{"_id":"drumkit","_rev":"9-6c813b138821bbb0dfbd9595237119fd","name":"drumkit","description":"Plugin Driven, Full Stack Web Framework for Node.js","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.1":{"name":"drumkit","description":"Plugin Driven, Full Stack Web Framework for Node.js","version":"0.1.1","author":{"name":"Chris Powers","email":"chrisjpowers@gmail.com"},"repository":{"type":"git","url":"git://github.com/chrisjpowers/drumkit.git"},"dependencies":{"underscore":"1.x.x","coffee-script":"1.x.x"},"bin":{"drumkit":"bin/drumkit"},"main":"./lib/drumkit.coffee","engines":{"node":">= 0.4.x"},"devDependencies":{},"_npmUser":{"name":"chrisjpowers","email":"chrisjpowers@gmail.com"},"_id":"drumkit@0.1.1","optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.1","_nodeVersion":"v0.6.11","_defaultsLoaded":true,"dist":{"shasum":"61c3aa5f8e68bf6275db2f63851f28b5f387daf9","tarball":"https://registry.npmjs.org/drumkit/-/drumkit-0.1.1.tgz","integrity":"sha512-HODN4FLxJj74oVc0TzThcu4at06Xo6g0xKKXe3zoG11Rzslv5Q0sn2nnhZtRRGdi986OZ3LAqMnH1FqDVjtvMA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIESrYgzV7BPrZuPywcRqmaU7RBhJjeLnTjRLjINkJIHeAiEAjYVJ6ZC5t3c3FpGINjeWvJTDOOeB1mQLCLK8ccfLbHk="}]},"maintainers":[{"name":"chrisjpowers","email":"chrisjpowers@gmail.com"}],"directories":{}}},"readme":"# DrumKit\n\n**WARNING! This framework is currently in very early development, it may be broken or may break at any time.**\n\nDrumKit is a plugin-powered, full-stack Web development framework for Node.js.\n\n## Installation\n\nDrumKit is dependent on Node.js and NPM. If you have both, you can install DrumKit globally:\n\n```bash\nnpm install -g drumkit\n```\n\nIt is important to install this globally so that you have access to the `drumkit` command across your system.\nAll DrumKit modules on the other hand will be installed locally in each of your DrumKit projects.\n\n## Getting Started\n\nDrumKit will bootstrap a project directory for you with the `create` command:\n\n```bash\ncd ~/myapps\ndrumkit create new-app\n```\n\nThis will generate a DrumKit application in `~/myapps/new-app` and will use `npm` to install\nyour dependencies. Once your app is installed, you can start the server:\n\n```bash\ncd new-app\ndrumkit start\n```\n\nBy default, your app will be running at `http://localhost:8765`.\n\n## Running the Console\n\nYou also can interact with your code in a REPL by firing up the console:\n\n```bash\ncd path/to/your/app\ndrumkit console\n```\n\n## Now Build Your App!\n\n1. Build models with [dk-model](http://github.com/chrisjpowers/dk-model#readme) (see also [dk-model-couchdb](http://github.com/chrisjpowers/dk-model-couchdb#readme) and [dk-couchdb](http://github.com/chrisjpowers/dk-couchdb#readme)).\n\n2. Build view templates and helpers with [dk-template](http://github.com/chrisjpowers/dk-template#readme).\n\n3. Build routes with [dk-routes](http://github.com/chrisjpowers/dk-routes#readme).\n\n4. Check out these other DrumKit plugins:\n  \n  * [dk-assets](http://github.com/chrisjpowers/dk-assets#readme)\n  * [dk-core](http://github.com/chrisjpowers/dk-core#readme)\n  * [dk-server](http://github.com/chrisjpowers/dk-server#readme)\n  * [dk-transport](http://github.com/chrisjpowers/dk-transport#readme)\n  * [dk-websockets](http://github.com/chrisjpowers/dk-websockets#readme)\n\n5. Build your own plugins with `drumkit plugin [pluginName]`\n\n\n\n\n# dk-core\n\n**WARNING! This framework is currently in very early development, it may be broken or may break at any time.**\n\nThe `dk-core` plugin provides core functionality for the DrumKit.js framework. Currently it has no configuration\noptions.\n\n## Installation\n\nInstall the package with `npm`:\n\n```bash\nnpm install dk-core\n```\n\n## Available Commands\n\n### drumkit start [env]\n\n`cd` into a project directory and run `drumkit start` to start up your DrumKit.js application. \nThe `env` defaults to `development`.\n\n### drumkit console [env]\n\n`cd` into a project directory and run `drumkit console` to start up your application in a \ncoffeescript REPL console. The `env` defaults to `development`.\n\n### drumkit consolejs [env]\n\nWorks the same as `drumkit console` except it uses straight JavaScript rather than CoffeeScript.\n\n### drumkit plugin pluginName\n\nBootstraps a new Drumkit plugin at ./plugins/pluginName.\n\n\n\n\n\n# dk-assets\n\nAn Asset Manager Plugin for DrumKit.js\n\n**WARNING! This framework is currently in very early development, it may be broken or may break at any time.**\n\n## Installation\n\nYou can install `dk-assets` using `npm`:\n\n```bash\nnpm install dk-assets\n```\n\n## Getting Started\n\nOut of the box, `dk-assets` assumes that you have a `public` folder with `js` and `css` subdirectories:\n\n```\n- public\n  - css\n  - js\n```\n\nAny files inside the `public` dir are automatically served, so `public/images/logo.png` will be available\nat `http://localhost:8080/images/logo.png`. You can change the location or name of your `public` directory\nby specifying it with `dk.assets.config`.\n\nAll JS and CSS files can be automatically packaged (concatenated) into single files for faster loading.\nYou can turn packaging on by running `dk.assets.config` with the `package` option set to `true`.\n\n\n## Plugin Developers Guide\n\nIf you have JS and/or CSS assets that you want included in the asset packages, use the `package` method.\nIt takes a the URL that you want to serve the asset at, followed by either the path to your static asset\nfile or a function that returns JS/CSS. If you package a coffeescript or stylus file, they will be automatically\ncompiled to JS and CSS on the fly:\n\n```coffeescript\n# Package a coffeescript file, serve at /js/my-file.js\ndk.assets.package \"/js/my-file.js\", \"#{__dirname}/some-dir/my-file.coffee\"\n\n# Package a stylus file, serve at /css/my-file.css\ndk.assets.package \"/css/my-file.css\", \"#{__dirname}/some-dir/my-file.stylus\"\n\n# Package the result of a function as a file\ndk.assets.package \"/js/dynamic.js\", ->\n  \"console.log('This could be something dynamically generated.');\"\n```\n\nFor assets in your plugin that you want to serve but **not** package (ie images), you can use\nthe `serve` method, which behaves similarly to `package`:\n\n```coffeescript\n# Serve a coffeescript file at /js/my-file.js\ndk.assets.package \"/js/my-file.js\", \"#{__dirname}/some-dir/my-file.coffee\"\n\n# Serve a stylus file at /css/my-file.css\ndk.assets.package \"/css/my-file.css\", \"#{__dirname}/some-dir/my-file.stylus\"\n\n# Serve the result of a function at /js/dynamic.js\ndk.assets.package \"/js/dynamic.js\", ->\n  \"console.log('This could be something dynamically generated.');\"\n```\n\n\n## Full API\n\n### dk.assets.config(options)\n\nAvailable options:\n\n* `dir`: (String) Sets the path to your public directory. All files in this directory will\n  be automatically served. __Defaults to \"public\"__\n* `package`: (Boolean) Sets whether `dk-assets` should package all JS and CSS files\n  into a single JS and CSS file (ie `/js/all.js` and `/css/all.css`). This is preferable\n  a production environment. __Defaults to false__ \n\n```coffeescript\n# Use a nonstandard public directory, package CSS and JS files\ndk.assets.config dir: \"nonstandard/public-dir\", package: true\n```\n\n### dk.assets.package(url, fileOrFunction, serve=true)\n\nUse the `package` method in order to make a JS or CSS file available at a given URL,\nand add it to the package. Any `coffeescript` or `stylus` file will automatically\nbe compiled on the fly.\n\n```coffeescript\n# Package a coffeescript file, serve at /js/my-file.js\ndk.assets.package \"/js/my-file.js\", \"#{__dirname}/some-dir/my-file.coffee\"\n\n# Package a stylus file, serve at /css/my-file.css\ndk.assets.package \"/css/my-file.css\", \"#{__dirname}/some-dir/my-file.stylus\"\n\n# Package the result of a function as a file\ndk.assets.package \"/js/dynamic.js\", ->\n  \"console.log('This could be something dynamically generated.');\"\n```\n\n### dk.assets.serve(url, fileOrFunction)\n\nServes the given file (or string generated by the passed function) at the URL. This file\nis **not** added to the JS or CSS packages, and will not be automatically loaded on\nthe page. Coffeescript and stylus code will be compiled on the fly.\n\n```coffeescript\n# Serve a coffeescript file at /js/my-file.js\ndk.assets.package \"/js/my-file.js\", \"#{__dirname}/some-dir/my-file.coffee\"\n\n# Serve a stylus file at /css/my-file.css\ndk.assets.package \"/css/my-file.css\", \"#{__dirname}/some-dir/my-file.stylus\"\n\n# Serve the result of a function at /js/dynamic.js\ndk.assets.package \"/js/dynamic.js\", ->\n  \"console.log('This could be something dynamically generated.');\"\n```\n\n### dk.assets.jsFiles()\n\nReturns an array of relative URLs for all packaged JS files. If the `package` option\nis `true`, it will return `[\"/js/all.js\"]`.\n\n```coffeescript\n# Get all the packaged JS URLs\ndk.assets.jsFiles() # returns [\"/js/thisFile.js\", \"/js/thatFile.js\", etc...]\n```\n\n### dk.assets.cssFiles()\n\nReturns an array of relative URLs for all packaged CSS files. If the `package` option\nis `true`, it will return `[\"/css/all.css\"]`.\n\n```coffeescript\n# Get all the packaged CSS URLs\ndk.assets.cssFiles() # returns [\"/css/thisFile.css\", \"/css/thatFile.css\", etc...]\n```\n\n\n\n\n# dk-couchdb\n\n**WARNING! This framework is currently in very early development, it may be broken or may break at any time.**\n\nThe `dk-couchdb` plugin gives you access to CouchDB databases in a DrumKit.js app.\n\n## Installation\n\nInstall the package locally with `npm`:\n\n```bash\nnpm install dk-couchdb\n```\n\n## On the Server\n\n### new dk.couchdb()\n\nCreate a database connection to a CouchDB instance running at `http://localhost:5984` by instantiating \na `dk.couchdb` object with your database name:\n\n```coffeescript\ndb = new dk.couchdb \"my-database-name\"\n```\n\nIf your CouchDB is running on another host or port, you can pass these in as options:\n\n```coffeescript\ndb = new dk.couchdb \"my-database-name\", host: \"myhost.com\", port: 1234\n```\n\n### db.get(id, function(err, data){})\n\nSingle documents can be fetched by `id` using the `get` instance method. This is an asynchronous\noperation, so the second argument is a required callback.\n\n```coffeescript\ndb.get \"some-id\", (err, doc) ->\n  if err\n    console.log \"Error: #{err}\"\n  else\n    console.log \"Got doc\", doc\n```\n\n### db.view(viewName, function(err, docs){})\n\nMultiple documents can be fetched using a CouchDB view with the `view` instance method. \nThis is an asynchronous operation, so the second argument is a required callback.\n\n```coffeescript\ndb.view \"my-design-doc/all\", (err, docs) ->\n  if err\n    console.log \"Error: #{err}\"\n  else\n    console.log \"Got docs\", docs\n```\n\n### db.save(data, function(err, doc){})\n\nYou can create or update a document using the `save` instance method. This is an asynchronous \noperation, so the second argument is a required callback. If the `data` has an `id` key, it will\nbe an update, otherwise `save` will create a new document.\n\n```coffeescript\ndata = {firstName: \"Chris\", lastName: \"Powers\"}\ndb.save data, (err, doc) ->\n  if err\n    console.log \"Error: #{err}\"\n  else\n    console.log \"Saved doc\", doc\n```\n\n### db.destroy(id, function(err){})\n\nYou can remove a document from the database using the `destroy` instance method with the document id.\nThis is an asynchronous operation, so the second argument is a required callback.\n\n```coffeescript\ndb.destroy \"some-id\", (err) ->\n  if err\n    console.log \"Error: #{err}\"\n  else\n    console.log \"Removed the document\"\n```\n\n\n## In the Browser\n\nCurrently `dk-couchdb` is not available directly in the browser, use `dk-model` instead.\n\n\n\n\n\n# dk-model-couchdb\n\nA CouchDB Model adapter for DrumKit.\n\n**WARNING! This framework is currently in very early development, it may be broken or may break at any time.**\n\n## Installation\n\nInstall this plugin with `npm`:\n\n```bash\nnpm install dk-model-couchdb\n```\n\n## Getting Started\n\nAll you need to do is include this plugin in your `package.json` file and you should\nbe good to go. `dk-model-couchdb` will automatically hook into `dk-model` and\n`dk-couchdb` for you, so no configuration should be necessary on your end.\n\n\n\n\n\n\n# dk-model\n\n**WARNING! This framework is currently in very early development, it may be broken or may break at any time.**\n\nThe `dk-model` plugin provides a database-agnositic persistence layer API to \nDrumKit.js that can be used both on the server and the browser.\n\n## Installation\n\nInstall `dk-model` using `npm`:\n\n```bash\nnpm install dk-model\n```\n\n\n## Getting Started\n\nBy default, `dk-model` expects your project to have a `models` directory that \nwill automatically load your model files from there. If you want to use a \ndifferent directory, you can configure the `dir` option:\n\n```coffeescript\ndk.model.config dir: \"#{__dirname}/nonstandardModelDir\"\n```\n\nModel classes are created using the `dk.model` method, which takes the model name \nand a callback as parameters. The callback function will be called with your new\nmodel class as the an argument. Inside the callback function is where you should\nadd instance methods, class methods and properties to your class. For example:\n\n```coffeescript\ndk.model \"User\", (User) ->\n  # These are the attributes that will be persisted\n  User.property \"firstName\", String\n  User.property \"lastName\", String\n\n  # Class methods, this will print:\n  #   Property: firstName, Type: String\n  #   Property: lastName, Type: String\n  User.printProperties = ->\n    for name, type of this.properties\n      console.log \"Property: #{name}, Type: #{type}\"\n\n  # Instance methods (ie methods on prototype object)\n  User::fullName = ->\n    \"#{@firstName} #{@lastName}\"\n```\n\nModel classes are generated by the CoffeeScript `class` construct, so you are\nable to use prototypal inheritance.\n\nTo access your new model class in other files you can use the `dk.model` method\nwithout the callback:\n\n```coffeescript\nUser = dk.model \"User\"\njohn = new User firstName: \"John\", lastName: \"Smith\"\njohn.fullName() # returns \"John Smith\"\n```\n\n## CRUD Operations\n\nThe goal of `dk-model` is to provide the developer with a database agnostic\npersistence API that will proxy CRUD operations to the appropriate persistence\nplugin. For example, the `dk-model-couchdb` plugin acts as an adapter between\n`dk-model` and `dk-couchdb`.\n\nAll the methods listed below will be available both on the server and browser,\nas will your custom model methods.\n\nAll CRUD operations are asyncronous and require callback functions as their last\nparameter. The callback functions generally are passed any resulting errors as\ntheir first parameter and an object (or array of objects) as the second.\n\n## Class Methods\n\n### new MyModel(attributes={})\n\nInstances of a model class are initialized using the `new` constructor and take\nan object of attributes as the first parameter.\n\n```coffeescript\nUser = dk.model \"User\"\nuser = new User firstName: \"John\", lastName: \"Smith\"\n```\n\n### .all(options, function(err, objects))\n\nFetches all records based on the `options` that are passed (`options` may be\ndifferent across adapters).\n\n```coffeescript\nUser = dk.model \"User\"\nUser.all {}, (err, users) ->\n  if err\n    console.log \"Error fetching users:\", err\n  else\n    for user in users\n      console.log \"Fetched\", user.fullName()\n```\n\n### .get(id, function(err, object))\n\nFetches a single record by its identifier.\n\n```coffeescript\nUser = dk.model \"User\"\nUser.get 123, (err, user) ->\n  if err\n    console.log \"Error fetching user:\", err\n  else\n    console.log \"Fetched\", user.fullName()\n```\n\n### .save(attributes, function(err, object))\n\nAttempts to create a new record with the given attributes, or update\na record if attributes has an `id`.\n\n```coffeescript\nUser = dk.model \"User\"\nUser.save firstName: \"John\", lastName: \"Smith\", (err, user) ->\n  if err\n    console.log \"Error creating user:\", err\n  else\n    console.log \"Created\", user.fullName()\n\nUser.save id: 123, firstName: \"Jane\", lastName: \"Doe\", (err, user) ->\n  if err\n    console.log \"Error updating user:\", err\n  else\n    console.log \"Updated\", user.fullName()\n```\n\n### .create(attributes, function(err, object))\n\nRight now this simply aliases `save`.\n\n### .destroy(id, function(err))\n\nDeletes the record with the given `id`.\n\n```coffeescript\nUser = dk.model \"User\"\nUser.destroy 123, (err) ->\n  if err\n    console.log \"Error destroying user:\", err\n  else\n    doSomethingElse()\n```\n\n## Instance Methods\n\n### save(function(err, object))\n\nSaves the given model object. If it is a new record, then the object passed\ninto the callback will have its new id.\n\n```coffeescript\nUser = dk.model \"User\"\nuser = new User firstName: \"John\"\nuser.lastName = \"Smith\"\nuser.save (err, obj) ->\n  if err\n    console.log \"Error saving user:\", err\n  else\n    console.log \"New user's id is\", obj.id\n```\n\n### destroy(function(err))\n\nDeletes the given model object from persistence (currently the JS object\nwill remain in memory).\n\n```coffeescript\nUser = dk.model \"User\"\nUser.get 123, (err, user) ->\n  user.destroy (err) ->\n    if err\n      console.log \"Error destroying user:\", err\n    else\n      console.log \"Just destroyed\", user.fullName()\n```\n\n## TODO\n\nThis still needs **a lot** of work and love, including but not limited to:\n\n* Validation\n* Better error handling\n* Using promises rather than callbacks\n* More adapters\n\n\n\n\n\n\n# dk-routes\n\n**WARNING! This framework is currently in very early development, it may be broken or may break at any time.**\n\nThis is a DrumKit plugin that adds URL routing on both the server and browser.\n\n## Installation\n\nInstall `dk-routes` with `npm`:\n\n```bash\nnpm install dk-routes\n```\n\n## Getting Started\n\nThe `dk-routes` plugin assumes that you have a `routes.coffee` file that defines\nall your routes. To use a different file, pass the `path` option to `config`:\n\n```coffeescript\ndk.routes.config path: \"#{__dirname}/nonstandard-path.coffee\"\n```\n\nInside this file you can define your routes, which will be available both on the\nserver and on the browser. The routes DSL provides you with the top level methods\n`get`, `post`, `put` and `del` (delete). Each of these methods takes three parameters --\na route URL, an optional helper method name and a function. For example:\n\n```coffeescript\nget \"/users\", \"users\", ->\n  dk.model(\"User\").all {}, (err, users) =>\n    this.render \"users\", users: users\n```\n\nIn the above example, when either the server or the browser receives a request\nfor the url `/users`, it will fetch all the `User` objects and use them to\nrender the `users` view. Also, because `\"users\"` was passed as the second parameter\nto `get`, the helper method `usersPath` will be added to all templates.\n\nNote that in the example, the callback passed to the `User.all` method uses the\ndouble arrow `=>` rather than the single `->`. This is done to maintain the value of\n`this` inside the callback because inside routes, `this` points to a special\n`RouteContext` object.\n\n## RouteContext\n\nInside of any route function, `this` refers to a `RouteContext` object. These\nobjects have two purposes:\n\n1. Make request details available (ex. params)\n2. Provide route actions (ex. rendering, redirects)\n\nHere is the current (limited) API:\n\n### params(paramName)\n\nReturns the value of the request param with the given name. This param could be\nin the URL, the querystring or a POST message body.\n\n```coffeescript\nget \"/users/:id\", \"user\", ->\n  dk.model(\"User\").get this.params(\"id\"), (err, user) =>\n    this.render \"user\", user: user\n```\n\n### render(templateName, locals)\n\nRenders the template with the given `templateName` using the given `locals`.\n\n```coffeescript\nget \"/users/:id\", \"user\", ->\n  dk.model(\"User\").get this.params(\"id\"), (err, user) =>\n    this.render \"user\", user: user\n```\n\n### redirect(path)\n\nRedirect the user to the given path.\n\n```coffeescript\npost \"/users\", ->\n  dk.model(\"User\").create this.params(\"user\"), (err, user) =>\n    this.redirect \"/users/#{user.id}\"\n```\n\n### title(str)\n\nSets the value of the page `title` tag.\n\n```coffeescript\nget \"/users/:id\", \"user\", ->\n  dk.model(\"User\").get this.params(\"id\"), (err, user) =>\n    this.title \"User: #{user.fullName()}\"\n    this.description \"This is a page about #{user.fullName()}\"\n    this.render \"user\", user: user\n```\n\n### description(str)\n\nSets the value of the page description meta tag.\n\n```coffeescript\nget \"/users/:id\", \"user\", ->\n  dk.model(\"User\").get this.params(\"id\"), (err, user) =>\n    this.title \"User: #{user.fullName()}\"\n    this.description \"This is a page about #{user.fullName()}\"\n    this.render \"user\", user: user\n```\n\n## TODO\n\nTons of work still needed on this, especially:\n\n* Figure out how to keep browser from overwriting what server generates\n* Build out `RouteContext` to have more request data and actions\n* Allow routes file to be straight JS\n* More routing features\n\n\n\n\n\n# dk-server\n\nHTTP Server Plugin for DrumKit.js\n\n**WARNING! This framework is currently in very early development, it may be broken or may break at any time.**\n\n## Installation\n\nYou can install `dk-server` using `npm`:\n\n```bash\nnpm install dk-server\n```\n\n## Getting Started\n\nThis module is meant to be pretty low-level, so application developers should not need to ever\nuse it directly. If you need to setup URLs and respond to HTTP requests, you should probably be\nusing the `dk-routes` plugin.\n\n## Plugin Developers Guide\n\nThe `dk-server` plugin acts as a `Connect` compliant server to allow you to respond to requests\nand wire up middleware. You are given `get`, `post`, `put`, `del` and `use`. This module cannot\nbe used on the browser.\n\n```coffeescript\ndk.server.get \"/hello\", (req, res) ->\n  res.send \"Hello there!\"\n\nconnect = require \"connect\"\ndk.server.use connect.logger(format: \":method :url\")\n```\n\n**NOTE: If you need to serve asset files (JS, CSS, images), use `dk-assets`.**\n\n\n\n\n\n\n\n# dk-template\n\nServer and Browser Templating for DrumKit.js\n\n**WARNING! This framework is currently in very early development, it may be broken or may break at any time.**\n\n## Installation\n\nYou can install `dk-template` using `npm`:\n\n```bash\nnpm install dk-assets\n```\n\n## Getting Started\n\nOut of the box, `dk-template` assumes that you have a `views` directory that holds all of your templates.\nIf you need to customize this, you can do so in your app configuration:\n\n```coffeescript\ndk.template.config dir: \"/path/to/my/views\"\n```\n\nCurrently `dk-template` supports `.eco` and `.ejs` templates. Other rendering engines can easily be\nadded (see Plugin Developers Guide). The `render` method takes a template name and a context object,\nreturning the rendered template as a string:\n\n```html\n<!-- in views/js-user.ejs -->\n<p>My name is <%= user.name %> and I like straight JS.</p>\n\n```html\n<!-- in views/coffee-user.eco -->\n<p>My name is <%= @user.name %> and I prefer CoffeeScript.</p>\n\n```coffeescript\n# In my CoffeeScript source\n\ndk.template.render \"js-user\", user: {name: \"John\"}\n# => returns \"<p>My name is John and I like straight JS.</p>\"\n\ndk.template.render \"coffee-user\", user: {name: \"Jane\"}\n# => returns \"<p>My name is Jane and I prefer CoffeeScript.</p>\"\n\nThe `render` method is available both on the server and the browser. Please refer \nto the EJS and ECO projects' documentation for a full explanation of their features.\n\n\n## View Helper Methods\n\nTo add helper methods that will be available to all templates, use the \n`dk.template.helpers.add` method in your `helpers.coffee` file:\n\n```html\n<!-- in views/quote.eco -->\n<p>Favorite Quote: \"<%= @truncate @quote, 10 %>\"</p>\n```\n\n```coffeescript\n# In helpers.coffee\ndk.template.helpers.add \n  truncate: (str, len) ->\n    if str.length > len\n      str.slice(0, len) + '...'\n    else\n      str\n```\n\n```coffeescript\n# Elsewhere in the app\ndk.template.render \"quote\", quote: \"Four score and seven years ago\"\n# returns '<p>Favorite Quote: \"Four score...\"</p>\n```\n\nHelper methods defined in your `helpers.coffee` file will be made available on\nboth the server and browser. If you want to define your helper methods in a file\nother than `helpers.coffee`, you can do so by using the `helpersPath` config option:\n\n```coffeescript\ndk.template.config helpersPath: \"#{__dirname}/nonstandardHelpersPath.coffee\n```\n\nAlso, you can use a `helpers.js` file instead if you prefer straight JS.\n\n\n## Plugin Developers Guide\n\nSupport for `.ejs`, `.eco` and `.mustache` files was added simply using Drumkit plugin extensions, so it is\neasy to create your own extensions to support other rendering engines. View the following files\nto see how it is done:\n\n* `lib/dk-template-eco.coffee`\n* `lib/dk-template-ejs.coffee`\n* `lib/dk-template-mustache.coffee`\n* `public/js/dk-template-eco.coffee`\n* `public/js/dk-template-ejs.coffee`\n* `public/js/dk-template-mustache.coffee`\n\n\n# dk.template.layout\n\nThis module is responsible for rendering full page layouts on the server. By default,\n`dk.template.layout` uses its own minimal layout, which is at `./views/layout.eco`. To use\nyour own custom layout file, use the `path` option of the `config` method.\n\n## dk.template.layout.config(options)\n\nAvailable options:\n\n* `path`: (String) An absolute path to your custom layout file. Defaults to using a built-in layout.\n* `title`: (String) A default page title, defaults to \"\".\n* `description`: (String) A default page description, defaults to \"\".\n\n```coffeescript\ndk.template.layout.config\n  path: \"#{__dirname}/views/layout.eco\"\n  title: \"My DrumKit App\"\n  description: \"This app was built using DrumKit.js\"\n```\n\n## dk.template.layout.render(templateName, context)\n\nRenders the template called `templateName` inside of your layout.\n\n**NOTE: The layout has these additional values available in its context:**\n\n* `content`: The rendered content of the inner view template `templateName`.\n* `title`: The page title.\n* `description`: The page description.\n\n```coffeescript\n# renders the 'users' template inside of the page layout\ndk.template.layout.render \"users\", users: [\"Bill\", \"Susan\"]\n```\n\n\n\n\n\n\n\n\n# dk-websockets\n\n**WARNING! This framework is currently in very early development, it may be broken or may break at any time.**\n\nThe `dk-websockets` plugin adds Websocket functionality to your DrumKit.js application.\n\n## Installation\n\nInstall the package with `npm`:\n\n```bash\nnpm install dk-websockets\n```\n\n## Getting Started\n\nFor general use you should not use `dk-websockets` directly -- use the higher-level `dk-transport` instead.\n\n## Plugin Developers Guide\n\nThe `dk.websockets` object is an `EventEmitter`, so you can listen for the following events:\n\n```coffeescript\ndk.websockets.on \"connection\", (client) ->\n  # do something\ndk.websockets.on \"message\", (msg) ->\n  # do something\ndk.websockets.on \"disconnect\", (client) ->\n  # do something\n```\n\n","maintainers":[{"name":"chrisjpowers","email":"chrisjpowers@gmail.com"}],"time":{"modified":"2022-06-16T00:38:41.041Z","created":"2012-02-21T15:25:19.132Z","0.1.2":"2012-02-21T15:25:20.828Z","0.1.1":"2012-02-28T22:58:38.176Z"},"author":{"name":"Chris Powers","email":"chrisjpowers@gmail.com"},"repository":{"type":"git","url":"git://github.com/chrisjpowers/drumkit.git"}}