Skip to content

Instantly share code, notes, and snippets.

@enjalot
Last active August 29, 2015 14:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enjalot/7cd061a66c61235de70b to your computer and use it in GitHub Desktop.
Save enjalot/7cd061a66c61235de70b to your computer and use it in GitHub Desktop.
component-examples
app = module.exports = require('derby').createApp 'component-examples', __filename
app.serverUse module, 'derby-stylus'
app.loadViews __dirname
app.loadStyles __dirname
app.use require 'l-progress/example'
# add more components here...
app.get '/', ->
componentNames = []
for viewName of app.views.nameMap
match = /^(l-.+)-example$/.exec viewName
componentNames.push match[1] if match
componentNames.sort (a,b) ->
return a.localeCompare(b)
@model.set '_page.componentNames', componentNames
@render 'home'
app.get '/:component', ->
@render @params.component + '-example'
app.on 'ready', (page) ->
# For debugging purposes only
window.MODEL = page.model
window.APP = app
<Title:>
{{$render.ns}} Example
<Body:>
<view name={{$render.ns}}></view>
<home:>
<ul class="list">
{{each _page.componentNames}}
<li><a href="/{{this}}">{{this}}</a></li>
{{/each}}
</ul>
@require './node_modules/l-progress'
.list
li
font-size: 25px
margin: 10px
padding: 10px
a
color: black
a:hover
color: blue
require('derby-starter').run __dirname, {port: 3300}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment