Created
February 22, 2012 14:56
-
-
Save ppcano/1885433 to your computer and use it in GitHub Desktop.
ember assetfile with less and 0.6 rake-pipeline
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CustomLessFilter < Rake::Pipeline::Filter | |
| include Rake::Pipeline::Web::Filters::FilterWithDependencies | |
| attr_reader :options | |
| def initialize(options={}, context = nil, &block) | |
| block ||= proc { |input| input.sub(/\.less$/, '.css') } | |
| super(&block) | |
| @options = options | |
| end | |
| def generate_output(inputs, output) | |
| parser = Less::Parser.new :paths => ['less'] | |
| inputs.each do |input| | |
| name = File.basename(input.path, '.less') | |
| //OJO: HERE... it will only load the main file which imports the other files | |
| output.write parser.parse(input.read).to_css if name == 'main' | |
| end | |
| end | |
| def external_dependencies | |
| [ 'less' ] | |
| end | |
| end | |
| input "less" do | |
| match "*.less" do | |
| filter CustomLessFilter | |
| concat "project.css" | |
| end | |
| end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "rake-pipeline-web-filters" | |
| require "json" | |
| require "less" | |
| class HandlebarsFilter < Rake::Pipeline::Filter | |
| def initialize(&block) | |
| block ||= proc { |input| input.sub(/\.handlebars$/, '.js') } | |
| super(&block) | |
| end | |
| def generate_output(inputs, output) | |
| inputs.each do |input| | |
| name = File.basename(input.path, '.handlebars') | |
| output.write "Ember.TEMPLATES['#{name}'] = Ember.Handlebars.compile(#{input.read.to_json});" | |
| #output.write "return Ember.Handlebars.compile(#{input.read.to_json})" | |
| end | |
| end | |
| end | |
| output "source" | |
| input "less" do | |
| match "main.less" do | |
| less :paths => ['less'] | |
| copy "project.css" | |
| end | |
| end | |
| input "templates" do | |
| # TODO: include in minispade | |
| match "*.handlebars" do | |
| filter HandlebarsFilter | |
| concat "templates.js" | |
| end | |
| end | |
| input "packages" do | |
| # also include app, it could be improved | |
| match "*/lib/**/*.js" do | |
| minispade :rewrite_requires => true, :string=> false, :module_id_generator => proc { |input| | |
| id = input.path.dup | |
| id.sub!('/lib/', '/') | |
| id.sub!(/\.js$/, '') | |
| id.sub!(/\/main$/, '') | |
| #id.sub!('/tests', '/~tests') | |
| id | |
| } | |
| filter ConcatFilter, "packages.js" | |
| end | |
| match "*.css" do | |
| filter ConcatFilter, "embermk.css" | |
| end | |
| end | |
| # TODO: ideally in the same file | |
| input "app" do | |
| match "*/lib/**/*.js" do | |
| minispade :rewrite_requires => true, :string=> false, :module_id_generator => proc { |input| | |
| id = input.path.dup | |
| id.sub!('/lib/', '/') | |
| id.sub!(/\.js$/, '') | |
| id.sub!(/\/main$/, '') | |
| #id.sub!('/tests', '/~tests') | |
| id | |
| } | |
| filter ConcatFilter, "app.js" | |
| end | |
| end | |
| # vim: filetype=ruby |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @import 'account'; | |
| @import 'brand'; | |
| @import 'button'; | |
| @import 'city'; | |
| @import 'comment'; | |
| @import 'common'; | |
| @import 'contacts'; | |
| @import 'footer'; | |
| @import 'invitation'; | |
| @import 'map'; | |
| @import 'me'; | |
| @import 'normalize'; | |
| @import 'popup'; | |
| @import 'product'; | |
| @import 'qr'; | |
| @import 'start'; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment