Module:ColorParse: Difference between revisions

259 bytes added ,  17:06, 25 May 2020
templates work?
m (fix conditional)
(templates work?)
Line 4: Line 4:
local textutil = require'Module:Text Utility'
local textutil = require'Module:Text Utility'
local process_args = require'Module:ProcessArgs'
local process_args = require'Module:ProcessArgs'
local shaders = require'Module:ColorParse/Templates'
local stringbyte, stringchar = string.byte, string.char
local stringbyte, stringchar = string.byte, string.char


Line 146: Line 147:
function p.shadermain(frame)
function p.shadermain(frame)
     local args = process_args.merge(true)
     local args = process_args.merge(true)
    if args['1'] and args['2'] then -- shader template
      output = p.applytemplate(args['1'], args['2'])
    else
      output = p.shader(args['text'], args['colors'], args['type'])
    end
     if (args['unbolded'] == 'true') then
     if (args['unbolded'] == 'true') then
       return p.shader(args['text'], args['colors'], args['type'])
       return output
     else
     else
       return '<b>' .. (p.shader(args['text'], args['colors'], args['type']) or '') .. '</b>'
       return '<b>' .. (output or '') .. '</b>'
     end
     end
end
function p.applytemplate(shader, text)
  return p.shader(text, shaders[shader][1], shaders[shader][2])
end
end


function p.test()
function p.test()
     return p.shader('structural', 'Y-y-K-y-Y', 'alternation')
     return p.applytemplate('structural', 'structural')
     --return p.shader('Stopsvalinn', 'R-r-K-y-Y', 'sequence')
     --return p.shader('Stopsvalinn', 'R-r-K-y-Y', 'sequence')
end
end


return p
return p