Skip to content

Instantly share code, notes, and snippets.

@CrabDude
Created April 1, 2012 18:30
Show Gist options
  • Save CrabDude/2277550 to your computer and use it in GitHub Desktop.
Save CrabDude/2277550 to your computer and use it in GitHub Desktop.
Tiki
<script>eval(localStorage.tiki)||function(q,l){(tiki=function(){q.push(arguments)}).q=q;(l||attachEvent)((l?"":"on")+"message",function(e){eval(e.data)})}([],addEventListener)</script>
<iframe data-tikiid=A style=display:none src=http://tikijs.net></iframe>
// See Asynchronous Module Definition (AMD) spec
// https://github.com/amdjs/amdjs-api/wiki/AMD
define('foo', ['bar', 'baz'], function(bar, baz) {
// Your code here
return {
id: 'foo',
bar: bar,
baz: baz
};
});
{ "name" : "foo",
"version" : "1.2.3",
"description" : "A packaged foo fooer for fooing foos",
"main" : "foo.js",
"dependencies": {
"bar": "0.1.x",
"baz": "*"
}
}
# Point npm to the tiki registry (3 options)
# option 1:
# to revert, comment out or delete line
echo "registry = "http://tikijs.net:5984/registry/_design/app/_rewrite" >> ~/.npmrc
# option 2:
# to revert, "npm config delete registry"
npm config set registry http://tikijs.net:5984/registry/_design/app/_rewrite
# option 3:
npm --registry http://tikijs.net:5984/registry/_design/app/_rewrite install <package>
# Publish as you would with npm
path/to/module$ npm publish
// Effortless module loading [1]
tiki(['jquery'], function(require, define) {
var jquery = require('jquery')
console.log('Tiki!Tiki! ', jquery)
})
// Automatic dependency resolution
// Loading underscore.string[2] includes & loads underscore
tiki(['underscore.string'], function(require, define) {
var _ = require('underscore.string')
console.log(_.repeat("Tiki!", 2))
})
// [1] http://jquery.com/
// [2] http://epeli.github.com/underscore.string/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment