Advertisement
Guest User

Lua HTML Tag Reader by WeBuLtRa

a guest
Nov 28th, 2011
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.72 KB | None | 0 0
  1. function echo(str)--Yeap, it has to be a global function
  2.     io.write(str);
  3. end
  4. function ExecuteLuaTags(str, sOut)
  5.     --[[returns true or nil + errmsg
  6.     Arg1 = string HTMLwithLuaTags;
  7.     Arg2 = outputFilepath]]--
  8.     io.output(sOut);
  9.     local ret, msg;
  10.     local function ParseLuaTag(str)
  11.         --By WeBuLtR@ hehehe
  12.         if not str:find("%%>$") then
  13.             str = str:gsub("(.+%%>)(.+)",
  14.                 function(a,b)
  15.                     return a.."echo([["..b.."]])";
  16.                 end
  17.             );
  18.         end
  19.         str = str:gsub("(.-)<%%lua(.-)%%>",
  20.                 function(s,b)
  21.                     return "echo([["..s.."]]) "..b;
  22.                 end
  23.             );
  24.         return str;
  25.     end
  26.     local a,b = pcall(loadstring,ParseLuaTag(str));
  27.     if a then
  28.         ret, msg = pcall(b);
  29.     else
  30.         ret, msg = nil, b;
  31.     end
  32.     io.close();
  33.     return ret, msg;
  34. end
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement