Generic JavaScript Object Parser Plugin

Plugin source location: <serge_root>/lib/Serge/Engine/Plugin/parse_js.pm

This plugin is used to parse JavaScript object properties in "key" : "value" format. It is also suitable to parse string maps in Go, since their syntax is very similar. Whitespace before and afer colon is ignored. Each key-value pair must be on its own line. If the line ends with a comment, it will be extracted as an additional hint as well. If the string key is identical to the string itself, it will not be extracted (since it adds no value).

Note that this parser supports only a subset of syntax and does no validation. It is targeted for arbitrary source code files. If your resource file is rather a well-formed JSON that can be strictly validated, you can use the parse_json_keyvalue plugin instead.

Code Examples

example.js
var localizations = { "key1" : "string", "key2": "string", // additional comment "key3":"string", //... "some string":"some string", "another string":"another string", //... };

Limitation: both key and value need to double-quoted. Single-quoted strings are not supported. Multi-line strings are not supported as well.

Usage

example-project.serge