Skip to content

Instantly share code, notes, and snippets.

@gabrielgrant
Last active October 26, 2018 22:21
Show Gist options
  • Save gabrielgrant/c313e36f1b8fb8f34afb52047b6cca9d to your computer and use it in GitHub Desktop.
Save gabrielgrant/c313e36f1b8fb8f34afb52047b6cca9d to your computer and use it in GitHub Desktop.
MVCE for emberjs/emberjs#15059
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('files', function() {
this.route('file', { path: '*path' });
});
this.route('rootfiles', function() {
this.route('rootfile', { path: ':path' });
});
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
model(params) {
return {
paramsPath: params.path,
decodedPath: decodeURI(params.path)
};
}
});
import Ember from 'ember';
export default Ember.Route.extend({
model(params) {
return {
paramsPath: params.path,
decodedPath: decodeURI(params.path)
};
}
});
<h1>Welcome to {{appName}}</h1>
<br>
{{link-to 'non-glob example' 'rootfiles.rootfile' '/files/my file with spaces.json'}}
{{link-to 'glob example' 'files.file' '/files/my file with spaces.json'}}
<br>
<br>
{{outlet}}
<br>
<br>
<p>params.path: {{model.paramsPath}}</p>
<p>decodeURI(params.path): {{model.decodedPath}}</p>
<p>params.path: {{model.paramsPath}}</p>
<p>decodeURI(params.path): {{model.decodedPath}}</p>
{
"version": "0.12.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment