Skip to content

Instantly share code, notes, and snippets.

Nicolas Carlo nicoespeon

Block or report user

Report or block nicoespeon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nicoespeon
nicoespeon / test.js
Created Mar 23, 2016
Blog - Testing Marionette.js Behaviors - mock view test
View test.js
describe( "Alert Behavior", () => {
let view;
beforeEach( () => {
view = Marionette.ItemView.extend( {
template: _.template( "" ),
behaviors: {
@nicoespeon
nicoespeon / view.js
Created Mar 23, 2016
Blog - Testing Marionette.js Behaviors - instantiated behavior
View view.js
const ShareView = Marionette.ItemView.extend( {
template: "#card",
behaviors: {
AlertOnShare: {
behaviorClass: AlertBehavior,
title: "Shared",
message: "Your message has been shared!"
}
@nicoespeon
nicoespeon / behavior.js
Last active Mar 23, 2016
Blog - Testing Marionette.js Behaviors - problem
View behavior.js
const Alert = Marionette.Behavior.extend( {
defaults: {
title: "Alert!",
message: "Not really urgent"
},
events: {
"click": "emitAlert"
},
@nicoespeon
nicoespeon / plopfile.js
Last active Mar 23, 2016
Blog - Plop — a micro-generator to ease your daily life - adapt actions to answers
View plopfile.js
module.exports = ( plop ) => {
plop.setGenerator( "module", {
prompts: [
{
type: "input",
name: "name",
message: "What is the name of your module?",
validate: isNotEmptyFor( "name" ),
@nicoespeon
nicoespeon / calendars.js
Last active Mar 23, 2016
Blog - Plop — a micro-generator to ease your daily life - calendars parsed
View calendars.js
import Module from "core/module";
import _ from "lodash";
// IMPORT MODULE FILES
import Model from "./calendars.model";
const namespace = "calendars";
Model = Model.extend( { namespace: namespace } );
@nicoespeon
nicoespeon / calendars.js
Last active Mar 23, 2016
Blog - Plop — a micro-generator to ease your daily life - calendars
View calendars.js
import Module from "core/module";
import _ from "lodash";
// IMPORT MODULE FILES
const namespace = "calendars";
export default Module.extend( {
initialize() {
@nicoespeon
nicoespeon / calendars.model.js
Last active Mar 23, 2016
Blog - Plop — a micro-generator to ease your daily life - calendars.model result
View calendars.model.js
/**
* TODO - Describe what your model does.
*
* @class Calendars.Model
* @module Calendars
* @constructor
*/
import {Model} from "backbone";
export default Model.extend( {
@nicoespeon
nicoespeon / model.js
Last active Mar 23, 2016
Blog - Plop — a micro-generator to ease your daily life - plop-template
View model.js
/**
* TODO - Describe what your model does.
*
* @class {{pascalCase name}}.Model
* @module {{pascalCase name}}
* @constructor
*/
import {Model} from "backbone";
export default Model.extend( {
@nicoespeon
nicoespeon / plopfile.js
Last active Mar 23, 2016
Blog - Plop — a micro-generator to ease your daily life - concrete example
View plopfile.js
const modulePath = "app/modules/{{camelCase name}}.js";
module.exports = ( plop ) => {
plop.setGenerator( "model", {
//
actions: [
// Add a new model + tests boilerplate.
@nicoespeon
nicoespeon / plopfile.js
Last active Mar 23, 2016
Blog - Plop — a micro-generator to ease your daily life - prompts
View plopfile.js
import {trimRight, isEmpty} from "lodash";
const ensurePlural = ( text ) => trimRight( text, "s" ) + "s";
const isNotEmptyFor = ( name ) => {
return ( value ) => {
if ( isEmpty( value ) ) return name + " is required";
return true;
}
}
You can’t perform that action at this time.