-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
104 additions
and
46 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
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 |
---|---|---|
@@ -1,11 +1,3 @@ | ||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) | ||
|
||
require 'bundler/setup' # Set up gems listed in the Gemfile. | ||
require 'rubygems' | ||
|
||
environment = ENV['RAILS_ENV'] || 'development' | ||
PRE_ASSEMBLY_ROOT = File.expand_path(File.dirname(__FILE__) + '/..') | ||
CERT_DIR = File.join(File.dirname(__FILE__), ".", "certs") | ||
|
||
# Environment. | ||
require_relative "cli_environments/#{environment}.rb" |
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,87 @@ | ||
require 'erubis' | ||
|
||
# This is essentially a modified copy of | ||
# https://raw.githubusercontent.com/rails/rails/v4.2.10/actionview/lib/action_view/template/handlers/erb.rb | ||
# It restores ActionView::Template::Handlers::Erubis removed in Rails 5.x | ||
# It also monkey-patches ERB to default to Erubis | ||
# relates to: https://github.com/haml/haml/issues/695 | ||
|
||
module ActionView | ||
class Template | ||
module Handlers | ||
class Erubis < ::Erubis::Eruby | ||
def add_preamble(src) | ||
@newline_pending = 0 | ||
src << "@output_buffer = output_buffer || ActionView::OutputBuffer.new;" | ||
end | ||
|
||
def add_text(src, text) | ||
return if text.empty? | ||
|
||
if text == "\n" | ||
@newline_pending += 1 | ||
else | ||
src << "@output_buffer.safe_append='" | ||
src << "\n" * @newline_pending if @newline_pending > 0 | ||
src << escape_text(text) | ||
src << "'.freeze;" | ||
|
||
@newline_pending = 0 | ||
end | ||
end | ||
|
||
# Erubis toggles <%= and <%== behavior when escaping is enabled. | ||
# We override to always treat <%== as escaped. | ||
def add_expr(src, code, indicator) | ||
case indicator | ||
when '==' | ||
add_expr_escaped(src, code) | ||
else | ||
super | ||
end | ||
end | ||
|
||
BLOCK_EXPR = /\s*((\s+|\))do|\{)(\s*\|[^|]*\|)?\s*\Z/ | ||
|
||
def add_expr_literal(src, code) | ||
flush_newline_if_pending(src) | ||
if code =~ BLOCK_EXPR | ||
src << '@output_buffer.append= ' << code | ||
else | ||
src << '@output_buffer.append=(' << code << ');' | ||
end | ||
end | ||
|
||
def add_expr_escaped(src, code) | ||
flush_newline_if_pending(src) | ||
if code =~ BLOCK_EXPR | ||
src << "@output_buffer.safe_expr_append= " << code | ||
else | ||
src << "@output_buffer.safe_expr_append=(" << code << ");" | ||
end | ||
end | ||
|
||
def add_stmt(src, code) | ||
flush_newline_if_pending(src) | ||
super | ||
end | ||
|
||
def add_postamble(src) | ||
flush_newline_if_pending(src) | ||
src << '@output_buffer.to_s' | ||
end | ||
|
||
def flush_newline_if_pending(src) | ||
if @newline_pending > 0 | ||
src << "@output_buffer.safe_append='#{"\n" * @newline_pending}'.freeze;" | ||
@newline_pending = 0 | ||
end | ||
end | ||
end | ||
|
||
class ERB # monkey-patch: restoring the default from rails 4 | ||
class_attribute :erb_implementation, default: Erubis | ||
end | ||
end | ||
end | ||
end |
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