Skip to content
This repository has been archived by the owner on May 26, 2019. It is now read-only.

Merged Guides content from https://github.com/emberjs/website/pull/1956 #7

Closed
wants to merge 73 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
32152a0
Merged Guides content from https://github.com/emberjs/website/pull/1956
bsclifton Feb 21, 2015
1bae5be
Merge remote-tracking branch 'upstream/master'
bsclifton Feb 21, 2015
8e7f446
Merge remote-tracking branch 'upstream/master'
bsclifton Feb 23, 2015
b48f40e
Integrated with https://github.com/bsclifton/middleman-swiftype (my f…
bsclifton Feb 23, 2015
882a653
Got the search.json file generating :) Included it with this commit; …
bsclifton Feb 23, 2015
27a8a60
Updated README w/ middleman-swiftype details
bsclifton Feb 24, 2015
8f848d9
Merge remote-tracking branch 'upstream/master'
bsclifton Feb 24, 2015
c98fc56
converted the first four articles
Feb 25, 2015
c0ae949
updating customizing
Feb 25, 2015
9275e8f
updated a jsbin
Feb 25, 2015
8eaf6b1
finished adding JSbins
Feb 25, 2015
04ea9b7
changing spaces to 2 instead of 4, reducing var CreateWhatever
Feb 26, 2015
9c3a326
more spacing and export changes
Feb 26, 2015
d8de0c8
indent inside if statement with 2 spaces
Feb 26, 2015
fad684f
JSBin changes and small space fixes
Feb 26, 2015
838c433
Merge remote-tracking branch 'upstream/master'
bsclifton Feb 27, 2015
c734afa
...
bsclifton Feb 27, 2015
363a9cd
README was updated to have publishing info; removed my version
bsclifton Feb 27, 2015
ff7bbc2
Updated reference to middleman-swiftype; also fixed some spelling err…
bsclifton Feb 28, 2015
03b739d
Merge remote-tracking branch 'upstream/master'
bsclifton Mar 3, 2015
518d8bb
Merge branch 'master' into feature/components-to-cli
Mar 7, 2015
9a32496
new formatting for file path
Mar 7, 2015
94338c3
new formatting for file path
Mar 7, 2015
88f1164
Merge branch 'master' into feature/components-to-cli
Mar 8, 2015
2d47c01
updating file path formatting
Mar 9, 2015
1f66b5b
commented out JSbins
nicolechung Mar 15, 2015
a265640
Merge remote-tracking branch 'upstream/master'
bsclifton Mar 15, 2015
3bff790
update with upstream master
nicolechung Mar 16, 2015
a366765
removed JSbins and added formatting to another file
nicolechung Mar 16, 2015
c91b169
Convert views (as best we can) to ember-cli
trek Mar 14, 2015
1bc227d
Merge pull request #56 from emberjs/cliify-views
rwjblue Mar 17, 2015
9cc35c1
Merge branch 'master' into feature/components-to-cli
Mar 17, 2015
4a4bdfa
fixes as per rwblue comments
Mar 17, 2015
e839694
fixes as per rwblue comments
Mar 17, 2015
0067c10
removing imports and newlines
Mar 17, 2015
1be7722
removed double 'a', indentation and incorrect file extension
Mar 17, 2015
cbcc7e8
removed indents
Mar 17, 2015
5ba9b55
Merge pull request #18 from nicolechung/feature/components-to-cli
rwjblue Mar 18, 2015
c247261
Add deprecations for non-block-param helpers
wagenet Mar 19, 2015
987a59a
Updates record lifecycle section for ember-cli
locks Mar 19, 2015
4a403a2
Merge pull request #63 from emberjs/non-block-param-deprecations
trek Mar 19, 2015
e185b8d
Merge pull request #64 from locks/ember-cli/understanding-ember-data
trek Mar 19, 2015
74ee238
Update routing documentation for Ember CLI
stevekinney Feb 24, 2015
c35e2bd
Updated per comments
bsclifton Mar 19, 2015
cefc28a
Removed Ember Inspector page in favor of all the great content in htt…
bsclifton Mar 19, 2015
cfa4d37
Update contributions section for CLI
stevekinney Mar 19, 2015
45371c5
Remove global from feature flag
stevekinney Mar 20, 2015
b6227f8
Merge pull request #69 from stevekinney/update-contributing-for-cli
mixonic Mar 20, 2015
83cf396
Remove deprecations page, which is part of main website
wagenet Mar 20, 2015
272486c
Updated `controllers` to use Ember CLI
Feb 22, 2015
3856673
Removed globals from object-model
Feb 25, 2015
406ae27
Don't import Ember
Mar 20, 2015
b5b2f51
Merge pull request #19 from joostdevries/rewrite-object-model-ember-cli
trek Mar 20, 2015
b1b1b47
Merge pull request #11 from joostdevries/controllers-to-cli
trek Mar 20, 2015
d4a8132
Updates "Models" section for ember-cli
locks Feb 22, 2015
ec7b2f2
Merge pull request #8 from locks/ember-cli/data
trek Mar 20, 2015
b79b7d4
Moves 'concepts' section to cli style
trek Mar 17, 2015
347c6a2
Merge pull request #70 from wagenet/remove-deprecations
trek Mar 20, 2015
890821e
Update "Cookbook" for ember-cli
Mar 20, 2015
f4644eb
Replaces "Getting Ember" for PR #7
locks Mar 19, 2015
ae32633
Merge pull request #60 from emberjs/cliify-concepts
trek Mar 20, 2015
abbb003
Merge pull request #25 from nicolechung/feature/cookbooks-to-cli
trek Mar 20, 2015
11cea20
Raise MissingLanguageError if no language is specified by Highlighter.
tundal45 Mar 13, 2015
4c2989e
Add unit tests to TOC.
tundal45 Mar 21, 2015
040ccbc
Introducing Travis CI
tundal45 Mar 17, 2015
9230754
Add fenced code block with language wherever necessary.
tundal45 Mar 21, 2015
c20c158
Merge pull request #73 from tundal45/add-fenced-code-blocks-with-lang…
trek Mar 21, 2015
6058db2
Merge pull request #53 from tundal45/handle-nil-language-in-highlighter
trek Mar 21, 2015
183e5c4
Merge pull request #14 from stevekinney/update-routes-sections-for-cli
trek Mar 21, 2015
7b7e906
Merge pull request #65 from locks/ember-cli/getting-ember
trek Mar 21, 2015
2b0f466
Merge pull request #62 from emberjs/cliify-understanding-ember
trek Mar 21, 2015
e94a966
converted the first four articles
Feb 25, 2015
a73dce0
Merge branch 'master' of https://github.com/bsclifton/guides
bsclifton Mar 21, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
language: ruby
rvm:
- "1.9.3"
script: bundle exec rspec spec && bundle exec middleman build
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ group :test do
gem "rspec"
gem "capybara"
gem "poltergeist"
gem "hashie"
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ GEM
ffi (1.9.6-x86-mingw32)
haml (4.0.6)
tilt
hashie (3.4.0)
highline (1.6.21)
hike (1.2.3)
hitimes (1.2.2)
Expand Down Expand Up @@ -203,6 +204,7 @@ DEPENDENCIES
builder
capybara
coderay!
hashie
highline
listen
middleman (~> 3.0)
Expand Down
16 changes: 8 additions & 8 deletions data/guides.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
url: ""
skip_sidebar: true

- title: "Getting Started"
url: 'ember-cli'
chapters:
- title: "Installing Ember"
url: "index"
- title: "Glossary"
url: "glossary"

- title: "Getting Ember"
url: 'getting-ember'
chapters:
Expand Down Expand Up @@ -198,8 +206,6 @@
url: "built-in-views"
- title: "Manually Managing View Hierarchy"
url: "manually-managing-view-hierarchy"
#- title: "Building Reusable Views"
#url: "building-reusable-views"

- title: "Enumerables"
url: 'enumerables'
Expand Down Expand Up @@ -375,12 +381,6 @@
# url: "debugging_and_configuration/setting_ember_global_flags"
# skip_sidebar_item: true

- title: "Deprecations"
url: 'deprecations'
chapters:
- title: "Deprecations"
url: "index"

- title: "Understanding Ember.js"
url: 'understanding-ember'
chapters:
Expand Down
7 changes: 7 additions & 0 deletions lib/highlighter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require "coderay"

module Highlighter
class MissingLanguageError < StandardError; end
class << self
def registered(app)
app.helpers Helpers
Expand All @@ -11,6 +12,11 @@ def registered(app)

module Helpers
def _highlight(string, language, class_name=nil)
error_message = "Code blocks must be fenced with proper language designated. If you don't know what language to use, specify ```text.\n\n"
error_message << "Offending Code Block:\n\n#{string}"

raise MissingLanguageError, error_message if language.nil?

language, file_name = _detect_language_and_filename(language)

result = %Q{<div class="highlight #{language} #{class_name}">}
Expand All @@ -23,6 +29,7 @@ def _highlight(string, language, class_name=nil)
end

def _detect_language_and_filename(language)

file_name = nil
bare_language_regex = /\A\w+\z/

Expand Down
29 changes: 16 additions & 13 deletions lib/toc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,13 @@ def toc_for(guides)
end

def page_title
buffer = ""

if current_guide
buffer << current_guide.title
if current_chapter
buffer << ": "
buffer << current_chapter.title
end
if current_guide && current_chapter
"#{current_guide.title}: #{current_chapter.title}"
elsif current_guide
current_guide.title
else
buffer << "Guides"
"Guides"
end

buffer
end

def guide_name
Expand All @@ -78,9 +72,9 @@ def guide_name

def chapter_name
if current_chapter
return current_chapter.title
current_chapter.title
else
return ""
""
end
end

Expand Down Expand Up @@ -111,6 +105,10 @@ def current_guide
end
end

def current_guide_index
data.guides.find_index(current_guide)
end

def current_chapter
return unless current_guide

Expand All @@ -123,6 +121,11 @@ def current_chapter
end
end

def current_chapter_index
return unless current_guide
current_guide.chapters.find_index(current_chapter)
end

def chapter_links
%Q{
<footer>
Expand Down
45 changes: 22 additions & 23 deletions source/components/customizing-a-components-element.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ To use a tag other than `div`, subclass `Ember.Component` and assign it
a `tagName` property. This property can be any valid HTML5 tag name as a
string.

```js
App.NavigationBarComponent = Ember.Component.extend({
```app/components/navigation-bar.js
export default Ember.Component.extend({
tagName: 'nav'
});
```

```handlebars
{{! templates/components/navigation-bar }}
```templates/components/navigation-bar.hbs
<ul>
<li>{{#link-to 'home'}}Home{{/link-to}}</li>
<li>{{#link-to 'about'}}About{{/link-to}}</li>
Expand All @@ -37,8 +36,8 @@ App.NavigationBarComponent = Ember.Component.extend({
You can also specify which class names are applied to the component's
element by setting its `classNames` property to an array of strings:

```javascript
App.NavigationBarComponent = Ember.Component.extend({
```app/components/navigation-bar.js
export default Ember.Component.extend({
classNames: ['primary']
});
```
Expand All @@ -47,8 +46,8 @@ If you want class names to be determined by properties of the component,
you can use class name bindings. If you bind to a Boolean property, the
class name will be added or removed depending on the value:

```js
App.TodoItemComponent = Ember.Component.extend({
```app/components/todo-item.js
export default Ember.Component.extend({
classNameBindings: ['isUrgent'],
isUrgent: true
});
Expand All @@ -65,8 +64,8 @@ If `isUrgent` is changed to `false`, then the `is-urgent` class name will be rem
By default, the name of the Boolean property is dasherized. You can customize the class name
applied by delimiting it with a colon:

```javascript
App.TodoItemComponent = Ember.Component.extend({
```app/components/todo-item.js
export default Ember.Component.extend({
classNameBindings: ['isUrgent:urgent'],
isUrgent: true
});
Expand All @@ -80,8 +79,8 @@ This would render this HTML:

Besides the custom class name for the value being `true`, you can also specify a class name which is used when the value is `false`:

```javascript
App.TodoItemComponent = Ember.Component.extend({
```app/components/todo-item.js
export default Ember.Component.extend({
classNameBindings: ['isEnabled:enabled:disabled'],
isEnabled: false
});
Expand All @@ -96,8 +95,8 @@ This would render this HTML:
You can also specify a class which should only be added when the property is
`false` by declaring `classNameBindings` like this:

```javascript
App.TodoItemComponent = Ember.Component.extend({
```app/components/todo-item.js
export default Ember.Component.extend({
classNameBindings: ['isEnabled::disabled'],
isEnabled: false
});
Expand All @@ -118,8 +117,8 @@ If the `isEnabled` property is set to `true`, no class name is added:
If the bound property's value is a string, that value will be added as a class name without
modification:

```javascript
App.TodoItemComponent = Ember.Component.extend({
```app/components/todo-item.js
export default Ember.Component.extend({
classNameBindings: ['priority'],
priority: 'highestPriority'
});
Expand All @@ -136,8 +135,8 @@ This would render this HTML:
You can bind attributes to the DOM element that represents a component
by using `attributeBindings`:

```javascript
App.LinkItemComponent = Ember.Component.extend({
```app/components/link-item.js
export default Ember.Component.extend({
tagName: 'a',
attributeBindings: ['href'],
href: "http://emberjs.com"
Expand All @@ -146,20 +145,20 @@ App.LinkItemComponent = Ember.Component.extend({

You can also bind these attributes to differently named properties:

```javascript
App.LinkItemComponent = Ember.Component.extend({
```app/components/link-item.js
export default Ember.Component.extend({
tagName: 'a',
attributeBindings: ['customHref:href'],
customHref: "http://emberjs.com"
});
```

### Example
<!-- ### Example

Here is an example todo application that shows completed todos with a
red background:

<a class="jsbin-embed" href="http://jsbin.com/duzala/1/embed?live">JS Bin</a><script src="http://static.jsbin.com/js/embed.js"></script>
<a class="jsbin-embed" href="http://jsbin.com/nefisejade/1/embed?live">JS Bin</a><script src="http://static.jsbin.com/js/embed.js"></script>

**Note:** The binding functionality in this very simple example could also be implemented without
the use of `Ember.Component` but by simply [binding element attributes](../../templates/binding-element-attributes) or [binding element class names](../../templates/binding-element-class-names).
the use of `Ember.Component` but by simply [binding element attributes](../../templates/binding-element-attributes) or [binding element class names](../../templates/binding-element-class-names). -->
63 changes: 44 additions & 19 deletions source/components/defining-a-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,56 @@ create a `components/blog-post` template.
but `post` is not. This prevents clashes with current or future HTML element names, and
ensures Ember picks up the components automatically.

If you are including your Handlebars templates inside an HTML file via
`<script>` tags, it would look like this:

```handlebars
<script type="text/x-handlebars" id="components/blog-post">
<h1>Blog Post</h1>
<p>Lorem ipsum dolor sit amet.</p>
</script>
```
A sample component template would look like this:

If you're using build tools, create a Handlebars file at
`templates/components/blog-post.handlebars`.
```app/templates/components/blog-post.hbs
<h1>Blog Post</h1>
<p>Lorem ipsum dolor sit amet.</p>
```

Having a template whose name starts with `components/` creates a
component of the same name. Given the above template, you can now use the
`{{blog-post}}` custom element:

```handlebars
<h1>My Blog</h1>
{{#each post in model}}
{{blog-post}}
<!--- <a class="jsbin-embed" href="http://jsbin.com/tikenoniku/1/edit?output">JS Bin</a><script src="http://static.jsbin.com/js/embed.js"></script> -->
<!--- The example above uses `<script>` tags to work inside of JSBin.-->
```app/templates/index.hbs
{{#each}}
{{#blog-post title=title}}
{{body}}
{{/blog-post}}
{{/each}}
```

<a class="jsbin-embed" href="http://jsbin.com/juvic/embed?js,output">JS Bin</a><script src="http://static.jsbin.com/js/embed.js"></script>
```app/templates/components/blog-post.hbs
<article class="blog-post">
<h1>{{title}}</h1>
<p>{{yield}}</p>
<p>Edit title: {{input type="text" value=title}}</p>
</article>
```

```app/routes/index.js
var posts = [{
title: "Rails is omakase",
body: "There are lots of à la carte software environments in this world."
}, {
title: "Broken Promises",
body: "James Coglan wrote a lengthy article about Promises in node.js."
}];

export default Ember.Route.extend({
model: function() {
return posts;
}
});
```

```app/components/blog-post.js
export default Ember.Component.extend({

});
```

Each component, under the hood, is backed by an element. By default
Ember will use a `<div>` element to contain your component's template.
Expand All @@ -55,9 +80,9 @@ changes to the component's element using JavaScript.

Ember knows which subclass powers a component based on its name. For
example, if you have a component called `blog-post`, you would create a
subclass called `App.BlogPostComponent`. If your component was called
`audio-player-controls`, the class name would be
`App.AudioPlayerControlsComponent`.
file at `app/components/blog-post.js`. If your component was called
`audio-player-controls`, the file name would be at
`app/components/audio-player-controls.js`

In other words, Ember will look for a class with the camelized name of
the component, followed by `Component`.
Expand Down
19 changes: 9 additions & 10 deletions source/components/handling-user-interaction-with-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,24 @@ bubble.
For example, imagine the following component that shows a post's title.
When the title is clicked, the entire post body is shown:

```handlebars
<script type="text/x-handlebars" id="components/post-summary">
<h3 {{action "toggleBody"}}>{{title}}</h3>
{{#if isShowingBody}}
<p>{{{body}}}</p>
{{/if}}
</script>
```app/templates/components/post-summary.hbs
<h3 {{action "toggleBody"}}>{{title}}</h3>
{{#if isShowingBody}}
<p>{{{body}}}</p>
{{/if}}
```

```js
App.PostSummaryComponent = Ember.Component.extend({
```app/components/post-summary.js
export default Ember.Component.extend({
actions: {
toggleBody: function() {
this.toggleProperty('isShowingBody');
}
}
});
```
<a class="jsbin-embed" href="http://jsbin.com/yuzena/embed?live">JS Bin</a><script src="http://static.jsbin.com/js/embed.js"></script>

<!---<a class="jsbin-embed" href="http://jsbin.com/ciwenemedi/1/embed?live">JS Bin</a><script src="http://static.jsbin.com/js/embed.js"></script>-->

The `{{action}}` helper can accept arguments, listen for different event
types, control how action bubbling occurs, and more.
Expand Down
Loading