andykais / scrape-pages

generalized scraper using a single instruction set for any site that can be statically scraped
https://scrape-pages.js.org
MIT License
6 stars 2 forks source link

Improve config checking: ensure mustache variables exist #25

Open andykais opened 5 years ago

andykais commented 5 years ago

Using this issue as a guide: https://github.com/janl/mustache.js/issues/538 it is possible to extract the variable names for a template. Therefore, I should be able to check if a given template is using valid variable names. E.g.

// check against builtin variables
"https://example.com/post/{value}/comments/{index}" // valid

// given { "input": ["search", "user"] }
"https://example.com/user/{user}/search/{search}" // valid
"https://example.com/user/{user}/search/{someotherval}" // invalid
andykais commented 5 years ago

also useful: https://github.com/wycats/handlebars.js/issues/1207. Consider using the barhandles repo