Sha256: aeac3909392f52e6b8a1b8bf01b9527d0c9b114bacecde2e1fb12afbc8249c9c
Contents?: true
Size: 1.52 KB
Versions: 1
Compression:
Stored size: 1.52 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 def matches(ext, convertible) return true if convertible.data[:template_engine] == "slim" super(ext) end def output_ext(ext) ext == ".slim" ? ".html" : ext end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bridgetown-slim-1.1.0 | lib/bridgetown-slim/slim_templates.rb |