Fix helpers by surrounding nameLookup output with parentheses.

Handlebars helpers were broken due to `nameLookup` generating an
unexpected ternary in the compiled code's helper lookup expression.
Replace deprecated $.size() with $.length.

This eases compatibility with jQuery analogues like cheerio.
Access global namespace in a more generic manner.

This helps when running in a non-browser environment like node.