Sha256: 80f33295b56c78806285adb3c9a36dba2cacd5f7bb5377769f27940110dbf053

Contents?: true

Size: 983 Bytes

Versions: 5

Compression:

Stored size: 983 Bytes

Contents

module MasterView
  module Directives

    # Inserts a comment into the file that indicates that this file was generated
    # and should not be edited, else changes could be lost. The standard generated-file
    # comment includes the path to the original file that should be edited.
    # 
    class InsertGeneratedComment < MasterView::DirectiveBase

      # Configured value for generated comment text is eval'd to support #{template_path} field substitution
      Comment_eval_template = 'comment_text = "' + MasterView::GeneratedCommentText + '"'

      metadata :priority => 'VeryLow',
        :category => 'internal'

      attr_arg :comment_template_path

      event :after_stag do
        template_path = @comment_template_path
        comment_text = ''
        eval(Comment_eval_template, binding)
        comment = "\n<%\n#{comment_text}\n-%>" # "\n#{ERB_EVAL_START.strip()}\n#{comment_text}\n#{ERB_EVAL_END.strip()}"
        render comment
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
masterview-0.3.1 lib/masterview/directives/insert_generated_comment.rb
masterview-0.3.2 lib/masterview/directives/insert_generated_comment.rb
masterview-0.3.0 lib/masterview/directives/insert_generated_comment.rb
masterview-0.3.3 lib/masterview/directives/insert_generated_comment.rb
masterview-0.3.4 lib/masterview/directives/insert_generated_comment.rb