satyr/coco — Issue #101: [Idea] Inlines in the Code Generation
Author: ceymard
Created: 2011-10-19 19:55:38+00:00
State: open

It would be great if there was a flag on the command line that would allow inlining helper functions.

Eg. In the CouchDB NodeJS driver, you can specify "views" directly in a Javascript object. Theses views are functions that are passed to `.toString()`, which gives their text body.

Another example ; in my template language (JinJS), I declare filters that are to be embedded into the resulting templates the same way.

The problem is that whenever I use, say, `import`, the `__import` function is defined at toplevel, therefore rendering the isolated `.toString()` functions useless since this part is not embedded.

So, it would be cool that a switch could allow us to generate `a <<< b` as

```javascript
for (var key in src) {
if ({}.hasOwnProperty.call(src, key)) {
a[key] = b[key];
}
}
```

This may be complicated, I don't know, but it would sure be useful, since I could still use coco instead of having to going back to javascript in those cases.