| Webscript: Guidelines | |
| ident function | Identifies the webscript to the library. |
| ident: Required fields | Must set the following fields. |
| query_formats function | Queries the available formats to an URL. |
| query_formats: Required fields | Must set the following fields. |
| query_formats: Errors | Parsing errors should raise an error. |
| parse function | Parses the media details. |
| parse: Required fields | Must set the following fields. |
| parse: Optional fields | Set these if data is available or otherwise applicable. |
| parse: Notes | Important notes. |
| parse: Errors | Parsing (e.g. |
| General Tips | Useful tips. |
| Additional modules | Additional modules with functions. |
| Idioms | Useful lua idioms. |
| See also | Related pages. |
Useful lua idioms.
/* Consider the following in C */ b = (a == 1) 0:1;
-- Equivalent in lua: b = (a == 1) and 0 or 1
Armed with this knowledge, consider the following.
local foo
if bar == 'baz' then
foo = 'foo'
else
foo = 'bar'
endCould also be written like this.
local foo = (bar == 'baz') and 'foo' or 'bar'