Skip to content

Commit

Permalink
Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewRadev committed Aug 22, 2016
1 parent 9d5b0a3 commit 0394ca7
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions doc/ember_tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,81 @@ emblem template, but if you'd like to specify explicitly what templates you
prefer, set the |g:ember_tools_default_logic_filetype| and/or
|g:ember_tools_default_template_filetype| configuration variables.

*ember_tools-:Unpack*
:Unpack ~

The `:Unpack` command helps you unpack an imported variable into its component
pieces. An example might looks something like this:

>
import Ember from 'ember';
export default Ember.Controller.extend({
foo: Ember.computed.equal('bar', 'baz')
});
<
Running the `:Unpack` command with the cursor on "Ember.Controller" would lead
to the following result:
>
import Ember from 'ember';
const { Controller } = Ember;
export default Controller.extend({
foo: Ember.computed.equal('bar', 'baz')
});
<
The command creates a `const { ... } = ` line that unpacks the `Ember`
variable's `Controller` component into its own variable.

You can continue to run `:Unpack` on, for instance, "Ember.computed.equal",
and then once again on the remaining "computed.equal" (if you have repeat.vim
installed, you can just trigger the |.| mapping) to get:
>
import Ember from 'ember';
const { Controller, computed } = Ember;
const { equal } = computed;
export default Controller.extend({
foo: equal('bar', 'baz')
});
<
The command adds new entries to the end of the list. If you'd like to sort
them in some way afterwards, you can try using a different plugin of mine,
sideways (https://github.com/AndrewRadev/sideways.vim).

*ember_tools-:Inline*
:Inline ~

The `:Inline` command inlines an "unpacked" variable. If you have code like
this:
>
import Ember from 'ember';
const { computed, Controller } = Ember;
export default Controller.extend({
foo: computed.equal('bar', 'baz')
bar: computed.equal('baz', 'qux')
});
<
Running `:Inline` on "computed" within the `const { ... }` definition will
remove it from that list and replace it across the file (ignoring strings and
comments) with "Ember.computed".
>
import Ember from 'ember';
const { Controller } = Ember;
export default Controller.extend({
foo: Ember.computed.equal('bar', 'baz')
bar: Ember.computed.equal('baz', 'qux')
});
<
For now, this is simply a reversal of the `:Unpack` command. In the future,
the `:Inline` command might also inline other kinds of constructs, like local
variables or properties.


==============================================================================
Expand Down

0 comments on commit 0394ca7

Please sign in to comment.