Skip to content

Instantly share code, notes, and snippets.

@danmeyers
Last active May 20, 2020 20:55
Show Gist options
  • Select an option

  • Save danmeyers/7882ebc3225b30e2c590d95f5d851daf to your computer and use it in GitHub Desktop.

Select an option

Save danmeyers/7882ebc3225b30e2c590d95f5d851daf to your computer and use it in GitHub Desktop.
New Twiddle
import Component from '@ember/component';
export default Component.extend({
propFromJs: "that comes from JS tooo"
});
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
<strong>Here, we can mix common elements of a component that can be repeated, with configurable sections from the parent:</strong><br/><br/>
{{#pricing-plan as |plan|}}
{{#if plan.ctaSection}}
<em>Contextual from parent:</em>
In the parent of the component, I can insert stuff for the CTA section.
{{/if}}
{{#if plan.pricingSection}}
<em>Contextual from parent:</em>
In the parent of the component, I can insert stuff for the pricing section.
{{/if}}
{{/pricing-plan}}
<br/><br/><br/>
<strong>And we can repeat again, with different contextual text:</strong><br/><br/>
{{#pricing-plan as |plan|}}
{{#if plan.ctaSection}}
<em>Contextual from parent:</em>
<strong>First different from before.</strong>
{{/if}}
{{#if plan.pricingSection}}
<em>Contextual from parent:</em>
<strong>Second different from before.</strong>
{{/if}}
{{/pricing-plan}}
<em>In component</em>: Header with common stuff {{propFromJs}}
<br>
<br>
{{yield (hash ctaSection=true)}}
<br>
<br>
<em>In component</em>: Between CTA and pricing specifics
<br>
<br>
{{yield (hash pricingSection=true)}}
<br>
<br>
<em>In component</em>: After pricing specifics
{
"version": "0.17.1",
"EmberENV": {
"FEATURES": {},
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false,
"_APPLICATION_TEMPLATE_WRAPPER": true,
"_JQUERY_INTEGRATION": true
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js",
"ember": "3.18.1",
"ember-template-compiler": "3.18.1",
"ember-testing": "3.18.1"
},
"addons": {
"@glimmer/component": "1.0.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment