Sha256: eaaff35ca05bdc95c6d4baf620e713a62dd3a51b0cb273557ede99510e05b02d

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

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 Insert_generated_comment < MasterView::DirectiveBase

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

      def priority
        DirectivePriorities::VeryLow
      end

      def stag(directive_call_stack)
        # do variable substitution to fill in any slots in the template
        template_path = attr_value
        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()}"

        ret = []
        ret << directive_call_stack.render
        ret << comment
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
masterview-0.2.4 lib/masterview/directives/insert_generated_comment.rb
masterview-0.2.3 lib/masterview/directives/insert_generated_comment.rb
masterview-0.2.5 lib/masterview/directives/insert_generated_comment.rb