ractivejs/ractive — pull request #1456 by evs-chris (2014-11-08 03:50:45+00:00)
Title: Scoped inline partials and named yields - RFC

This attempts to address a handful of issues ( #583, #1317, #1429, #1173 ). It basically moves inline partial parsing to the conversion process instead of having a shotgun regex extraction before beginning conversion. After the template is parsed, the partial nodes are extracted from the template and attached to the parent nearest instance (base or component). This allows:

```html
{{>part1}}

I am part1 in the base instance

I am part1 attached to this cmp

```

`cmp` can have a template (or partials) include `{{>part1}}`, and the instance from the template will have its provided partial overridden with the inline partial. Partials can still be defined anywhere in the template, and they will still be stuck on their nearest Ractive parent.

### Named yields

Yielders get an extra conversion step, like partial context, that allows a name to be specified after `yield` e.g. `{{yield foo}}`. Instead of referencing a single `yieldTemplate` though, they reference either the root content of the component (internally represented as the name `''`) or an inline partial from the content of the component. Only inline partials from the component content can be referenced. The same rule of one yielder per component still applies, but it is expanded to one yielder per name per component.

```html

base content

I can be yielded

{{#yield foo}}
the same
{{/yield}}
```

### Issues
* There are no tests yet.
* Only allows `{{ }}` and `[[ ]]` for inline partials definitions. This can be addressed. It is left out for now because I didn't want to create a regex for every parse attempt for partials.
* If there isn't a base instance with all necessary components in place passed to the parser, the components won't get their inline partials. I don't think components work if they aren't already available at fragment-making time anyway.
* Yielders and inline partials can be mixed within a component, which may be confusing. I see that as beneficial, though.
* The differences between partials and yielders has blurred in my head, so I'm not sure I haven't broken something terribly. The existing tests pass though.