Class: Middleman::Renderers::Sass::SassPlusCSSFilenameTemplate
- Inherits:
-
Tilt::SassTemplate
- Object
- Tilt::SassTemplate
- Middleman::Renderers::Sass::SassPlusCSSFilenameTemplate
- Defined in:
- lib/middleman-core/renderers/sass.rb
Overview
A SassTemplate for Tilt which outputs debug messages
Direct Known Subclasses
Instance Method Summary collapse
-
#evaluate(context, _) ⇒ String
Add exception messaging.
-
#initialize(*args, &block) ⇒ SassPlusCSSFilenameTemplate
constructor
A new instance of SassPlusCSSFilenameTemplate.
- #prepare ⇒ Object
-
#sass_options ⇒ Hash
Change Sass path, for url functions, to the build folder if we're building.
-
#syntax ⇒ Symbol
Define the expected syntax for the template.
Constructor Details
#initialize(*args, &block) ⇒ SassPlusCSSFilenameTemplate
Returns a new instance of SassPlusCSSFilenameTemplate.
39 40 41 42 43 |
# File 'lib/middleman-core/renderers/sass.rb', line 39 def initialize(*args, &block) super @context = @options[:context] if @options.key?(:context) end |
Instance Method Details
#evaluate(context, _) ⇒ String
Add exception messaging
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/middleman-core/renderers/sass.rb', line 56 def evaluate(context, _) @context ||= context sass_module = if defined?(::SassC) ::SassC else ::Sass end @engine = sass_module::Engine.new(data, ) begin @engine.render rescue sass_module::SyntaxError => e ::Sass::SyntaxError.exception_to_css(e) end end |
#prepare ⇒ Object
51 |
# File 'lib/middleman-core/renderers/sass.rb', line 51 def prepare; end |
#sass_options ⇒ Hash
Change Sass path, for url functions, to the build folder if we're building
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/middleman-core/renderers/sass.rb', line 76 def ctx = @context more_opts = { load_paths: ::Sass.load_paths | ctx.app.config[:sass_assets_paths], filename: eval_file, line: line, syntax: syntax, custom: {}.merge!([:custom] || {}).merge!( middleman_context: ctx.app, current_resource: ctx.current_resource ) } if ctx.app.config[:sass_source_maps] || (ctx.app.config[:sass_source_maps].nil? && ctx.app.development?) more_opts[:source_map_file] = '.' more_opts[:source_map_embed] = true more_opts[:source_map_contents] = true end if ctx.is_a?(::Middleman::TemplateContext) && file more_opts[:css_filename] = file.sub(/\.s[ac]ss$/, '') end {}.merge!().merge!(more_opts) end |
#syntax ⇒ Symbol
Define the expected syntax for the template
47 48 49 |
# File 'lib/middleman-core/renderers/sass.rb', line 47 def syntax :sass end |