Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dump angular rails templates in favor of home grown - see pitr/angula…
- Loading branch information
Mr Rogers
committed
May 30, 2018
1 parent
c103166
commit 0882ee7
Showing
6 changed files
with
56 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
(function(){ | ||
'use strict'; | ||
|
||
angular.module('templates', []).run(['$templateCache', function($templateCache) { | ||
<%= | ||
|
||
environment.context_class.instance_eval { include ActionView::Helpers::JavaScriptHelper } | ||
|
||
def put_template_cache_js_command(key, html) | ||
"$templateCache.put(\"#{key}\", \"#{escape_javascript(html)}\");" | ||
end | ||
base_dir = Rails.root.join(*%w(app assets components)).to_s + "/" | ||
handle_slim_file = Proc.new do |file| | ||
key = file.gsub(%r(^#{base_dir}), '').gsub(/.slim$/,'') | ||
html = Slim::Template.new(file, {}).render(self).squish | ||
put_template_cache_js_command(key, html) | ||
end | ||
handle_html_file = Proc.new do |file| | ||
key = file.gsub(%r(^#{base_dir}), '') | ||
html = File.read(file).squish | ||
put_template_cache_js_command(key, html) | ||
end | ||
templates = File.join(base_dir, %w{** *.html}) | ||
slim_templates = File.join(base_dir, %w{** *.html.slim}) | ||
begin | ||
Dir.glob(templates).map(&handle_html_file) + | ||
Dir.glob(slim_templates).map(&handle_slim_file) | ||
end.join("\n"); | ||
%> | ||
}]); | ||
}()); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
Mau::Application.configure do | ||
# config.angular_templates.module_name = 'templates' | ||
# config.angular_templates.ignore_prefix = %w(templates/) | ||
# config.angular_templates.inside_paths = [Rails.root.join('app', 'assets')] | ||
# config.angular_templates.htmlcompressor = false | ||
config.angular_templates.markups = %w[erb slim] | ||
require 'fileutils' | ||
|
||
if Rails.env.development? | ||
cache_path = Rails.root.join('tmp', 'cache', 'assets', 'sprockets') | ||
FileUtils.rm_rf(cache_path) | ||
|
||
listener = Listen.to(Rails.root.join('app', 'assets', 'components')) do |_modified, _added, _removed| | ||
# clearing cache | ||
FileUtils.rm_rf(cache_path) | ||
end | ||
listener.start | ||
end |