Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View barneycarroll's full-sized avatar
🛠️
Working on Mithril type stuff

Barney Carroll barneycarroll

🛠️
Working on Mithril type stuff
View GitHub Profile
var mod = ( function initModulator(){
if( !Map ){
// A naive shim for maps functionality
var Map = shim;
var WeakMap = shim;
}
// Garbage collection flag
mod.cleanup = true;
m.validator = function (model, validations) {
this.errors = {}
this.validations = validations
this.model = model
}
m.validator.prototype.hasErrors = function () {
return Object.keys(this.errors).length
}
// MODEL
'use strict';
var m = require('mithril');
module.exports = function get_himage(){
return m.request({
method: 'GET',
url: '/config.json'
})
.then(function (data) {
@barneycarroll
barneycarroll / application.controller.js
Last active December 15, 2015 11:57 — forked from SirZach/application.controller.js
Can't access object values by dynamic key in Handlebars
import Ember from 'ember';
export default Ember.Controller.extend({
numbers:['1','2','3','4'],
letters:['a','b','c','d']
});
var m = require('mithril');
var layout = require('./components/layout/layout.js');
m.route.mode = 'pathname';
var Account = require('./models/account.model');
authRoutes(document.getElementById('app'), '/', layout.wrap({
'/': require('./pages/dashboard.js'),
@barneycarroll
barneycarroll / app.js
Last active March 24, 2016 11:59 — forked from tobyzerner/app.js
Mithril ES6 Components
// No dependencies! + 1 point
// Only one API to reference! + 1 point
const Widget = {
// Expose desired data directly using destructuring! + 1 point
controller({initialValue}) {
// No more retrieving references buried by the superclass! + 1 point
this.counter = initialValue;
// Two less methods! + 2 points
},
var m = require( 'mithril' )
var isSelected = require( '../functions/isSelected' )
function action(option, selection, e){
if (isSelected(ctrl.option, ctrl.selection)) {
var i = ctrl.selection.indexOf(ctrl.option)
ctrl.selection.splice(i, 1)
} else {
@barneycarroll
barneycarroll / breadcrumb.js
Last active August 4, 2016 13:02
breadcrumb
var m = require('mithril');
var _ = require('lodash');
breadcrumb.view = function (ctrl,array) {
return m('.breadcrumb', [
_.map(array, function (b, i) {
return m('.breadcrumb', [
m('i.material-icons', 'chevron_right'),
m('a.breadcrumb-link', {
href: b.url,
import m from 'mithril'
import store from '../../store'
import {loadUsers} from '../../data/users/actions'
import layout from '../../components/layout'
if (typeof require.ensure !== 'function') require.ensure = (d, c) => c(require)
async function getJs(){
return (await require('./users.js')).default
}