Class: Deplate::Command::ARG

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



361
362
363
364
365
366
367
368
369
370
371
372
# File 'lib/deplate/commands.rb', line 361

def accumulate(src, array, deplate, text, match, args, cmd)
    Deplate::Core.log("%s: %s" % [cmd, text], :debug, src)
    id = args['id'] || text
    val = deplate.variables[id] || args['default']
    if val
        acc = preformat_element(val, args)
        d = deplate.options.master ? deplate.options.master : deplate
        d.include_stringarray(acc, array, src.begin, src.file)
    else
        Deplate::Core.log(['Unknown variable', id, cmd], :error, src)
    end
end

.preformat_element(elt, args) ⇒ Object



374
375
376
377
378
379
380
381
382
383
# File 'lib/deplate/commands.rb', line 374

def preformat_element(elt, args)
    case elt
    when Array
        elt = elt.collect {|text| preformat_text(text, args)}
    else
        elt = preformat_text(elt, args)
    end
    elt.flatten!
    return elt
end

.preformat_text(text, args) ⇒ Object



385
386
387
388
389
# File 'lib/deplate/commands.rb', line 385

def preformat_text(text, args)
    text = Deplate::Core.escape_characters(text, args)
    text = Deplate::CommonGround.post_process_text(text, args)
    return text.split(/[\n\r]/).each {|l| l.chomp!}
end