Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I create a reusable partial for duplicate markup in ember.js?
    primarykey
    data
    text
    <p>Given this chunk of HTML:</p> <pre><code>&lt;div id="email_field" class="control-group"&gt; &lt;label class="control-label" for="account.email"&gt;Email&lt;/label&gt; &lt;div id="email_input" class="controls"&gt; &lt;input id="account.email" name="account.email" type="text" placeholder="jpublic@example.com"&gt; &lt;span class="help-block"&gt;We just need a valid email address.&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>How do I turn this into a re-usable partial for whatever attribute I want? IE: email, password, password confirmation, etc.</p> <p>I would assume some sort of view hierarchy but I'm not quite sure.</p> <p><strong>EDIT</strong>: After further exploration I've knocked out <code>{{view}}</code> and <code>{{render}}</code> and figured out exactly what I need:</p> <p>I want to: 1. Use a specific view (InputView) 2. Use a specific controller (Preferably similarly named: InputController) (<code>{{view}}</code> doesn't do this I think) 3. Be able to use this multiple times (<code>{{render}}</code> can't do this) 4. Be able to pass in values (<code>{{render}}</code> can't do this)</p> <p>Example:</p> <pre><code>&lt;!-- templates/application.hbs --&gt; {{foo "input" name="Email" id="account.email" placeholder="jpublic@email.com"}} </code></pre> <hr> <pre><code>// controllers/input.js Application.InputController = Ember.ObjectController.extend({ type: "text" }); </code></pre> <hr> <pre><code>// views/input.js Application.InputView = Ember.View.extend({ templateName: "form/input" }); </code></pre> <hr> <pre><code>&lt;!-- templates/form/input.hbs --&gt; &lt;input {{bindAttr id="id" name="name" type="type" placeholder="placeholder"}}&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload