Lua - Part 4

Jan 11, 2018

will probably use http.request (lua-http) instead of socket.http. Nope. Used socket.http.

luarocks install lua-cjson

luarocks install luasec

luarocks install http -- for lua-http above by daurnimator

for luasec:

local https = require("ssl.https")
local body, code, headers, status = https.request("")

old but interesting from the regex dude

Jan 18, 2018



web template

when i use open resty nginx, then i'll use this:

trying mustache.

general mustache templating info:

lua version:

Mustache appears to encode everything parsed through it as a {{variable}} but I don't want this to happen. How do I stop it in an instance of mustache? I don't want to break core code.

Your first option for doing variable interpolation without HTML escaping is to use either the triple mustache {{{unescapedInterpolation}}} tag (or its alternate-delimiter-friendly equivalent, {{&unescapedInterpolation}}).

All variables are HTML-escaped by default. If you want to render unescaped HTML, use the triple mustache: {{{name}}}. You can also use & to unescape a variable.

Jan 24, 2018

pattern matching


i'll need to install one or two xml/rss related modules.

Jan 31, 2018

installed luaexpat. update: i don't understand this module and usage. looking elsewhere. won't use this.

luarocks install luaexpat

luarocks install luacheck

Lua Object Model (LOM) is a representation of XML elements through Lua data types. Currently it is not supposed to be 100% complete, but simple.

More XML. - not for Lua v5.3

xml2lua is an XML parser written entirely in Lua which doesn't depend on any external C/C++ library. ---- answer suggested xmlreader

on feb 8, 2018, i installed this module.

luarocks install xmlua
luarocks install xmlua

forget this too.

It uses LuaJIT's FFI module.

That's a bigger install.

feb, 2018 cont.

now trying this

luarocks install luaxml

jeesh. just looking for a pure lua simple xml parser. i have little use for xml parsing, mainly for rss files and in the toledowx app, a custom xml file, provided by the nws.

JSON, JSON, JSON is way more preferred by me. far easier to deal with.

tried this:

manually copied down two lua files and placed them in my lib directory.

i don't understand any of this xml parsing. it's not mapping to what i would consider proper lua tables in an easy to understand format. this is insane.

i would advise never processing xml in lua. i just want lua tables that make sense. the crap produced by two of the above xml parsers is hideous.

Data Dumper

Penlight utilities - might be something to investigate.

It is often said of Lua that it does not include batteries. That is because the goal of Lua is to produce a lean expressive language that will be used on all sorts of machines, (some of which don’t even have hierarchical filesystems). The Lua language is the equivalent of an operating system kernel; the creators of Lua do not see it as their responsibility to create a full software ecosystem around the language. That is the role of the community.