Class: Deplate::Command::WITH

Inherits:
Deplate::Command show all
Defined in:
lib/deplate/commands.rb

Class Method Summary collapse

Methods inherited from Deplate::Command

commands, #finish, #format_special, #process, register_as, #setup, #setup_command, update_variables

Methods included from Names

name_match_c, name_match_fs, name_match_sf

Methods inherited from Element

#join_lines, #join_lines_re_zh_cn

Class Method Details

.accumulate(src, array, deplate, text, match, args, cmd) ⇒ Object



740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
# File 'lib/deplate/commands.rb', line 740

def self.accumulate(src, array, deplate, text, match, args, cmd)
    Deplate::Core.log("%s: %s" % [cmd, text], :debug, src)
    file = args["file"]
    body = nil
    if file
        File.open(file) {|io| body = io.readlines}
    else
        arg = args["arg"] || args["var"]
        if arg
            body = deplate.variables[arg]
            case body
            when String
                body = body.split(/[\n\r]/)
            end
        end
    end
    if body
        body.each {|l| l.chomp!}
        sep = "-=deplate=-%.10f-=end=-" % Time.new.to_f
        acc = ["#%s <<%s" % [text, sep], *body] << sep
        deplate.include_stringarray(acc, array, src.begin, src.file)
    else
        Deplate::Core.log(["No input! Skip", text], :error, src)
    end
end