cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

              <script type="text/x-handlebars" data-template-name="application">
  <h1>A test</h1>
  {{view App.CurrentUserView}}

<script type="text/x-handlebars" data-template-name="main">

<script type="text/x-handlebars" data-template-name="home">
  {{#linkTo posts.index}}See posts{{/linkTo}}

<script type="text/x-handlebars" data-template-name="current-user">
  {{#if view.isLoggedIn}}
    <a href="#" {{action logout}}>logout</a>
    {{#linkTo login}}Login{{/linkTo}}

<script type="text/x-handlebars" data-template-name="posts">

<script type="text/x-handlebars" data-template-name="posts/index">
  <p>view: posts/index</p>
  {{#linkTo comments.index}}See comments{{/linkTo}}

<script type="text/x-handlebars" data-template-name="post">
  <p>view: post</p>

<script type="text/x-handlebars" data-template-name="comments/index">
  <p>view: comments</p>
  {{#linkTo comments.show}}See comments{{/linkTo}}

<script type="text/x-handlebars" data-template-name="comments/show">
  <p>view: comments.show</p>

<script type="text/x-handlebars" data-template-name="login">
  <form {{action login content}}>
    {{view Ember.TextField valueBinding="content.username" placeholder="blah@diddy.com"}}
    {{view Ember.TextField valueBinding="content.password" placeholder="blah"}}
    {{#linkTo main}}cancel{{/linkTo}}
              App = Ember.Application.create();

// Create routes
  this.route("home", { path: "/home" });
  this.route("main", { path: "/" });
  // A resource is a grouping of routes
  //  - This will create routes posts.index and posts
  this.resource("posts", function(){
    this.resource("post", { path: "/1" }, function(){
      this.resource("comments", function(){

// A very basic user object we can bind to
//   in the view
App.User = Ember.Object.extend({
  username: null,
  isLoggedIn: false

// This route does the actual authentication logic
//  and redirects to the "secure" home route
//  this is called from the LoginController
App.LoginRoute = Ember.Route.extend({
  model: function(){
    return new App.User;
  events: {
    login: function(user){
      if(user.password == "blah"){
        var controller = this.controllerFor("application");
        controller.set("currentUser", user);
        user.set("isLoggedIn", true);

// ApplicationRoute allows for a logout action to
//  exist on any view in the app
//  also holds the global currentUser object
//  - Should logout be a route instead of an action?
App.ApplicationRoute = Ember.Route.extend({
  setupController: function(controller){
    var user = controller.get("currentUser") || App.User.create();
    controller.set("currentUser", user);
  events: {
    logout: function(){
      var controller = this.controllerFor("application");
      var user = controller.get("currentUser");
      user.set("isLoggedIn", false);

// CurrentUserView allows us to bind to "isLoggedIn" in
//  the current user view. That way anytime we change it,
//  it automatically toggles the login/logout display
App.CurrentUserView = Ember.View.extend({
  templateName: "current-user",
  isLoggedIn: function(){
    return this.get("controller.currentUser.isLoggedIn") == true;
  username: function(){
    return this.get("controller.currentUser.username");

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.


Loading ..................