Skip to content

Instantly share code, notes, and snippets.

AngularJS + Rails Asset Pipeline

This is my hand-rolled solution for getting Angular assets (Controllers, Models, Directives, Templates, etc.) integrated into the Rails Asset Pipeline.

Templates and the $templateCache

Of particular note: this hack will also load the AngularJS $templateCache with your templates, while allowing you to use Slim, ERB, etc. to write your templates.

'use strict'
var gulp, sass, babelify, browserify, watchify, source, util;
gulp = require('gulp');
sass = require('gulp-sass');
babelify = require('babelify')
browserify = require('browserify');
watchify = require('watchify');
source = require('vinyl-source-stream');
#
# Executes commands at the start of an interactive session.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Source Prezto.
# node version manager
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
@rocknrollMarc
rocknrollMarc / Gulpfile.js
Last active August 29, 2015 14:21
gulp-protractor-livereload
var gulp = require('gulp');
var livereload = require('gulp-livereload');
// The protractor task
var protractor = require('gulp-protractor').protractor;
// Start a standalone server
var webdriver_standalone = require('gulp-protractor').webdriver_standalone;
{
"app/assets/javascripts/router.js.coffee": {
"command": "jini"
},
"app/controllers/api/v1/*_controller.rb": {
"command": "apicontroller",
"alternate": "spec/controllers/api/v1/%s_controller_spec.rb",
"template": "class Api::V1::%SController < ApplicationController\n respond_to :json\nend"
},
"app/assets/javascripts/models/*.js.coffee": {
require "spec_helper"
describe ExampleController do
context "GET #index" do
let(:resources) { FactoryGirl.create_list(:resource) }
before do
get :index
end
# Ring the bell if any background window rang a bell
set -g bell-action any
# Default termtype. If the rcfile sets $TERM, that overrides this value.
set -g default-terminal screen-256color
# Keep your finger on ctrl, or don't
bind-key ^D detach-client
# Create splits and vertical splits
@rocknrollMarc
rocknrollMarc / deploy.zsh
Created March 17, 2015 12:50
github-pages-deployscript
#!/bin/zsh
echo -e "\033[0;32mDeploying updates to GitHub...\033[0m"
# Building the project.
hugo
# Add changes to git.
git add -A
@rocknrollMarc
rocknrollMarc / main.go
Last active August 29, 2015 14:16
Go webapp with gorilla and Negroni
package main
import (
"fmt"
"log"
"net/http"
"github.com/codegangsta/negroni"
"github.com/gorilla/mux"
"github.com/russross/blackfriday"
#### ####
#### ####
#### ####
#### ####
###########################################################################################
###########################################################################################
###########################################################################################
###########################################################################################
##########