Skip to content

Instantly share code, notes, and snippets.

View lifeart's full-sized avatar
🐹
Working from home

Alex Kanunnikov lifeart

🐹
Working from home
View GitHub Profile
@lifeart
lifeart / ember-cli-build.js
Last active January 28, 2022 18:57
Minimal Ember 3.28 app with runtime-defined components
'use strict';
const EmberApp = require('ember-cli/lib/broccoli/ember-app');
module.exports = function (defaults) {
let app = new EmberApp(defaults, {});
// we need to add emebr-template-compiler into runtime
app.import('node_modules/ember-source/dist/ember-template-compiler.js');
@lifeart
lifeart / index.js
Last active March 27, 2022 13:52
generic ember render tree capture
let EmberCore;
try {
EmberCore = requireModule('ember')['default'];
} catch {
EmberCore = window.Ember;
}
const keys = ['application','engine'];
//const isEmberApp = (el) => el._debugContainerKey && keys.includes(el._debugContainerKey.split(':')[0]);
@lifeart
lifeart / example.js
Created July 14, 2021 14:22
glimmer inline components
import SecondComponent from 'foo/bar';
function MyComponent(args) { return { a: 1, b: 2, c: args.e } }
function hasHelperManagerFor() {
return true;
}
function hasComponentManagerFor() {
@lifeart
lifeart / readme.md
Last active September 8, 2021 13:59
OSS readme.md

Application Name Gitter

Philosopher’s stone, logo of PostCSS

This is fancy application or library description.

import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
class ReactivePart {
constructor(placeholder) {
this.value = placeholder.replace('{{', '').replace('}}','');
this.placeholder = placeholder;
}
get isEditable() {
return this.placeholder.startsWith('{{');
@lifeart
lifeart / output.md
Last active May 11, 2021 21:06
simple html parser
[
  [ 'open-element', 'div ' ],
  [ 'open-mustache', 'foo-bar' ],
  [ 'close-mustache', ' ' ],
  [ 'self-close-element', '' ],
  [ 'in-element', '' ],
  [ 'open-element', 'a' ],
  [ 'in-element', '' ],
  [ 'open-mustache', 'boo' ],
import Component from '@glimmer/component';
export default class extends Component {
get items() {
return this.args.foo.length;
}
}
@lifeart
lifeart / example.ts
Last active March 12, 2021 13:15
ember template imports
import Component from "@glimmer/component";
import { helper } from "@ember/component/helper";
import { setComponentTemplate } from "@ember/component";
import { hbs as tpl } from "ember-cli-htmlbars";
function asHelper(a, b, c) {
return {
value: helper(function (positional) {
return c.value.call(a, ...positional);
})
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { schedule } from '@ember/runloop';
export default class ApplicationController extends Controller {
queryParams = ['inputValue'];
@tracked _inputValue = '';