Class: FlexibleInclude::FlexibleInclude

Inherits:
JekyllSupport::JekyllTag
  • Object
show all
Extended by:
FlexibleClassMethods
Includes:
FlexiblePrivateMethods, JekyllFlexibleIncludePluginVersion
Defined in:
lib/flexible_include.rb

Constant Summary

Constants included from FlexiblePrivateMethods

FlexibleInclude::FlexiblePrivateMethods::PREFIX, FlexibleInclude::FlexiblePrivateMethods::SUFFIX

Constants included from JekyllFlexibleIncludePluginVersion

JekyllFlexibleIncludePluginVersion::VERSION

Instance Method Summary collapse

Methods included from FlexibleClassMethods

access_allowed, escape_html, normalize_path, number_content, security_check

Methods included from FlexiblePrivateMethods

#denied, #highlight, #maybe_raise_error, #parse_args, #remove_html_tags, #render_completion, #run, #setup, #wrap_in_pre

Instance Method Details

#html_message(error) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/flexible_include.rb', line 28

def html_message(error)
  "    <div class='\#{error.class.name.snakecase}'>\n      \#{self.class} raised in \#{calling_file} while processing line \#{line_number} (after front matter) of \#{path}\n      \#{message}\n    </div>\n  END_MSG\nend\n"

#render_implObject

Look for *nix version of @path if Windows expansion did not yield a file that exists



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/flexible_include.rb', line 38

def render_impl
  setup
  # First expand bash environment variables ($VAR or ${VAR})
  path = ::JekyllSupport::JekyllPluginHelper.env_var_expand_bash(@filename, @logger)
  # Then expand Windows environment variables (%VAR%) for file paths
  @path = ::JekyllSupport::JekyllPluginHelper.env_var_expand_windows(path, @logger)
  linux_path = `wslpath '#{@path}' 2>/dev/null`.chomp
  @path = linux_path if !File.exist?(@path) && File.exist?(linux_path)
  handle_path_types
  render_completion
rescue Errno::EACCES => e
  e.shorten_backtrace
  @logger.error { "#{e.class.name}: #{e.message}" }
  exit! 1 if @die_on_file_error

  html_message
rescue Errno::ENOENT => e
  e.shorten_backtrace
  @logger.error { "#{e.class.name}: #{e.message}" }
  exit! 1 if @die_on_path_denied

  html_message
rescue FlexibleIncludeError => e
  @logger.error { e.logger_message }
  exit! if @die_on_other_error

  html_message
  # rescue StandardError => e
  #   @logger.error { e.full_message }
  #   exit! 4

  #   html_message
end