Sha256: 189d00374e9dbcade2f1600b5030fcffc254c7d388521a302f0784d4c886fc43
Contents?: true
Size: 1.32 KB
Versions: 2
Compression:
Stored size: 1.32 KB
Contents
# frozen_string_literal: true require "slim" module Bridgetown class SlimView < RubyTemplateView def partial(partial_name, options = {}) options.merge!(options[:locals]) if options[:locals] partial_segments = partial_name.split("/") partial_segments.last.sub!(%r!^!, "_") partial_name = partial_segments.join("/") Slim::Template.new( site.in_source_dir(site.config[:partials_dir], "#{partial_name}.slim") ).render(self, options) end end module Converters class SlimTemplates < Converter input :slim # Logic to do the Slim content conversion. # # @param content [String] Content of the file (without front matter). # @params convertible [Bridgetown::Page, Bridgetown::Document, Bridgetown::Layout] # The instantiated object which is processing the file. # # @return [String] The converted content. def convert(content, convertible) slim_view = Bridgetown::SlimView.new(convertible) slim_renderer = Slim::Template.new(convertible.relative_path) { content } if convertible.is_a?(Bridgetown::Layout) slim_renderer.render(slim_view) do convertible.current_document_output end else slim_renderer.render(slim_view) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bridgetown-slim-1.0.2 | lib/bridgetown-slim/slim_templates.rb |
bridgetown-slim-1.0.1 | lib/bridgetown-slim/slim_templates.rb |