Closed codez closed 13 years ago
good idea. can you provide example bash file?
A very simple test bash file with ERB would be
echo "Parsed at <%= Time.now %>"
echo "Executed at `Date`"
The ERB Bash scanner (based on Coderay RHTML and your Bash scanner) would then be very simple:
module CodeRay
module Scanners
class ErbBash < RHTML
register_for :erb_bash
protected
def setup
super
# Scan Bash instead of HTML template
@html_scanner = CodeRay.scanner :bash, :tokens => @tokens, :keep_tokens => true
end
end
end
end
I've added your ErbBash scanner to the git, made state and quote instance variables and add test for :erb_bash. I released it as v0.2.0 gem.
thx!
Great, we are using it already in our application.
When using instance instead of local variables for state and quote, it would be possible to re-use this scanner inside others (e.g. RHTML/ERB scanner with bash instead of html templates). If ERB is used within Bash quoted strings, the bash scanner continues in state :initial now after the ERB snippet instead of :quote.