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



235
236
237
238
239
240
241
242
243
# File 'lib/jekyll-content-security-policy-generator/hook.rb', line 235

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
  end

  write_file_contents(dest_path, output)
end

#write_file_contents(dest, content) ⇒ Object

Write the file contents back.



226
227
228
229
230
231
# File 'lib/jekyll-content-security-policy-generator/hook.rb', line 226

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