webmcp
view framework/env/format/file_path_element.lua @ 518:02d505b6090c
Added section about global variables and the environment to WebMCP's documentation
| author | jbe | 
|---|---|
| date | Mon Aug 21 14:50:27 2017 +0200 (2017-08-21) | 
| parents | a9fea293b2d6 | 
| children | 
 line source
     1 --[[--
     2 text =                     -- a string
     3 format.file_path_element(
     4   value,                   -- part of an encoded file path, see encode.file_path_element(...)
     5   options                  -- options as supported by format.string(...)
     6 )
     8 Undoes the encoding done by encode.file_path_element(...) and additionally formats the resulting string using the options available for format.string(...).
    10 --]]--
    12 function format.file_path_element(value, options)
    13   local options = options or {}
    14   if value == nil then
    15     return options.nil_as or ""
    16   else
    17     return format.string(
    18       string.gsub(
    19         tostring(value),
    20         "%%(%x%x)",
    21         function (hexcode)
    22           return string.char(tonumber("0x" .. hexcode))
    23         end
    24       ),
    25       options
    26     )
    27   end
    28 end
