Module: Jekyll::JekyllContentSecurityPolicyGenerator

Included in:
Document, Page
Defined in:
lib/jekyll-content-security-policy-generator/hook.rb

Defined Under Namespace

Classes: ContentSecurityPolicyGenerator

Instance Method Summary collapse

Instance Method Details

#write(dest) ⇒ Object

Write document contents



263
264
265
266
267
268
269
270
# File 'lib/jekyll-content-security-policy-generator/hook.rb', line 263

def write(dest)
  dest_path = destination(dest)
  if File.extname(dest_path) == ".html"
    content_security_policy_generator = ContentSecurityPolicyGenerator.new output
    output = content_security_policy_generator.run
    write_file_contents(dest_path, output)
  end
end

#write_file_contents(dest, content) ⇒ Object

Write the file contents back.



254
255
256
257
258
259
# File 'lib/jekyll-content-security-policy-generator/hook.rb', line 254

def write_file_contents(dest, content)
  FileUtils.mkdir_p(File.dirname(dest))
  File.open(dest, 'w') do |f|
    f.write(content)
  end
end