Skip to content

Instantly share code, notes, and snippets.

@vernondegoede
Last active February 29, 2016 13:20
Show Gist options
  • Save vernondegoede/dfde285a2ea7d289c4fc to your computer and use it in GitHub Desktop.
Save vernondegoede/dfde285a2ea7d289c4fc to your computer and use it in GitHub Desktop.
Rubymine Live Templates for Backbone.js & Marionette.js
App.module("App.$PARAM$", function ($PARAM$, App, Backbone, Marionette, $, _) {
'use_strict';
$PARAM$.Controller = {
showHomepage: function () {
this.entities = this.getEntities();
this.instantiateViews();
this.setViewHandlers();
this.renderViews();
$END$
},
getEntities: function () {
},
instantiateViews: function () {
},
setViewHandlers: function () {
},
renderViews: function () {
}
}
});
App.module("Entities", function (Entities, App, Backbone, Marionette, $, _) {
'use_strict';
Entities.Model = Backbone.Model.extend({
urlRoot: App.spree_endpoint + "$PARAM$",
defaults: {
}
});
Entities.Collection = Backbone.Collection.extend({
url: App.spree_endpoint + '$END$',
model: Entities.Model,
parse: function (response) {
return response;
}
});
});
App.module("$PARAM$", function ($PARAM$, App, Backbone, Marionette, $, _) {
'use_strict';
$PARAM$.Router = Marionette.AppRouter.extend({
appRoutes: {
"checkout(/)": "showCheckout"
},
controller: {
showCheckout: function () {
CheckoutsApp.Main.Controller.showCheckout();
}
}
});
$PARAM$.on("start", function () {
var Router = new $PARAM$.Router();
Backbone.Wreqr.radio.commands.setHandler('checkout', 'show', function () {
Router.controller.showCheckout();
});
});
});
<script type="text/template" id="tpl-$PARAM$">
$END$
</script>
App.module("App.$PARAM$", function ($PARAM$, App, Backbone, Marionette, $, _) {
'use_strict';
$PARAM$.View = Marionette.ItemView.extend({
template: "#tpl-",
className: "",
onShow: function () {
$END$
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment