Skip to content

Update for co-located templates (Part 1: "Getting Started") - #977

Merged
jenweber merged 2 commits into
octanefrom
co-located-templates
Aug 6, 2019
Merged

jenweber merged 2 commits into
octanefrom
co-located-templates

Conversation

@chancancode

Copy link
Copy Markdown
Contributor

This partly cover #973, #974 and #975 for the "Getting Started" section.

Since the generator will not generate a class by default, as I make edits for the co-location feature, it forces us into the right direction w.r.t. components-first.

@chancancode
chancancode changed the base branch from master to octane August 2, 2019 19:31
@chancancode
chancancode force-pushed the co-located-templates branch from 8e247cd to 770c12c Compare August 2, 2019 19:31
* It loads a model.
* It renders a template, which has access to the model.

## Models

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mostly just moved up from below.


We will cover these advanced component features in a later chapter.

## Lifecycle Hooks

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kind of out-of-scope for my PR, but should this section be removed? The router hook is can be covered in the route handler section above if we want, and the component hook part is largely not applicable in octane anymore (I think?)

@chancancode
chancancode requested review from jenweber and tomdale August 2, 2019 19:34

Templates can also display properties provided to them from their context, which is either a component or a route's controller. For example:
<div>
Hi <img src="{{this.model.profileImage}}" alt="{{this.model.name}}'s profile picture"> {{this.model.name}},

@chancancode chancancode Aug 2, 2019 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where my desire for @model came up – it would be nicer if we could consistently introduce everything with @args and avoid this.* until we have a need to teach adding a class for components. Having model exposed as this.model but not @model breaks that flow.

cc @locks @rwjblue @wycats

<rect x="459.5" y="820.6" fill="none" width="251.8" height="105.7"/>
<text transform="matrix(1 0 0 1 513.165 841.1191)" fill="#010101" font-family="'Lato-Bold'" font-size="27.4501">Component</text>
<text transform="matrix(1 0 0 1 476.4854 867.54)" fill="#010101" font-family="'Lato-Italic'" font-size="18.4908">app/components/rental-tile.js</text>
<text transform="matrix(1 0 0 1 476.4854 883.3818)" fill="#010101" font-family="'Lato-Italic'" font-size="14.5285">templates/components/rental-tile.hbs</text>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review this file with "Ignore Whitespace" mode turned on.

For example, a property rentals application would want to save the details of
a rental when a user publishes it, and so a rental would have a model defining
its details, perhaps called the _rental_ model. You may also need a _user_
model to keep track of who is currently logged in.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did add a sentence here to mention a user model, since it's referenced below.

@chancancode
chancancode force-pushed the co-located-templates branch from 770c12c to 0cdd97b Compare August 5, 2019 18:56
@jenweber
jenweber merged commit 11fb4e2 into octane Aug 6, 2019
@sivakumar-kailasam
sivakumar-kailasam deleted the co-located-templates branch August 13, 2019 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants