Sha256: 43a2cd4cbf11df602399d20ac21929c18d6532e38d30425c8da0c56c7331ccb6
Contents?: true
Size: 778 Bytes
Versions: 1
Compression:
Stored size: 778 Bytes
Contents
module Middleman module GeneratorTag class Extension < ::Middleman::Extension def initialize(app, options_hash = {}, &block) super extension = self app.after_render do |content| if %r{</html>} =~ content html = Nokogiri::HTML(content) if html.css("meta[name='generator']").length.zero? content = extension.insert_tag(html) end end content end end def insert_tag(html) title = html.at_css('title') meta = Nokogiri::XML::Node.new 'meta', html meta[:name] = 'generator' meta[:content] = "Middleman v#{::Middleman::VERSION}" title.add_next_sibling(meta) html.to_s end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
middleman-generator-tag-0.2.5 | lib/middleman-generator-tag/extension.rb |