Class: MinispadeRails::DirectiveProcessor
- Inherits:
-
Sprockets::DirectiveProcessor
- Object
- Sprockets::DirectiveProcessor
- MinispadeRails::DirectiveProcessor
- Defined in:
- lib/minispade-rails/directive_processor.rb
Instance Method Summary collapse
Instance Method Details
#process_require_spade_directive(path = ".") ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/minispade-rails/directive_processor.rb', line 30 def process_require_spade_directive(path = ".") if relative?(path) root = pathname.dirname.join(path). unless (stats = stat(root)) && stats.directory? raise ArgumentError, "require_spade argument must be a directory" end context.depend_on(root) @spades ||= [] each_entry(root) do |pathname| if context.asset_requirable?(pathname) context.depend_on pathname @spades << pathname end end else # The path must be relative and start with a `./`. raise ArgumentError, "require_spade argument must be a relative path" end nil end |
#process_source ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/minispade-rails/directive_processor.rb', line 4 def process_source super if @spades output = @spades.map do |spade| # Create a custom context for the spade require attributes = context.environment.attributes_for(spade) spade_context = context.environment.context_class.new(context.environment, attributes.logical_path, spade) # Add the minispade custom processor as the last item processors = [ *attributes.processors, MinispadeRails::Compiler ] # Remove the directive processors for the individual file processors.delete(Sprockets::DirectiveProcessor) # Evaluate the spade spade_context.evaluate(spade, :processors => processors) end # Prepend the requires @result = output.join("") + @result end @result end |