css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              h1 Z-router

    a(href="#/") home
    a(href="#/user") user
    a(href="#/user/42") users/42

              *, *:before, *:after
  margin: 0
  padding: 0
  box-sizing: border-box
  font-size: 20px
  font-family: sans-serif
  color: #444
  margin: 1rem 2rem

  display: block
    display: inline-block
    list-style-type: none
    margin: .5rem
      display: inline-block
      padding: .6em 1em
      background: #eee
      border-radius: .3em
      color: inherit
      text-decoration: none
        background: #AAA
  padding: 1em
  border: .2em solid #444
  margin: 1em 0 
              //Z-router script
var ZRouter=function(e,t){var r={routes:[],root:"/",el:"#z-router-view",loaderTpl:"<p>Loading...</p>",getTemplate:function(e){if(e.template)n.render(r.tp(e.template,e.options)),"function"==typeof e.callback&&e.callback(e.options);else if(e.templateUrl){n.render(r.loaderTpl);var t=new XMLHttpRequest;t.onreadystatechange=function(){4==t.readyState&&200==t.status?(e.template=t.responseText,n.render(r.tp(t.responseText,e.options)),"function"==typeof e.callback&&e.callback(e.options)):404==t.status&&n.render("<h1>Error "+t.status+"</h1>")},t.open("GET",e.templateUrl,!0),t.send()}},getFragment:function(){""===t.location.hash&&(t.location.hash="#"+r.root);var e=t.location.href.match(/#(.*)$/),n=e?e[1]:"";return n.toString()},tp:function(e,t){for(var r,n=/<%([^%>]+)?%>/g,o=/(^( )?(if|for|else|switch|case|break|{|}))(.*)?/g,a="var r=[];\n",l=0,c=function(e,t){return a+=t?e.match(o)?e+"\n":"r.push("+e+");\n":""!==e?'r.push("'+e.replace(/"/g,'\\"')+'");\n':"",c};r=n.exec(e);)c(e.slice(l,r.index))(r[1],!0),l=r.index+r[0].length;return c(e.substr(l,e.length-l)),a+='return r.join("");',new Function(a.replace(/[\r\t\n]/g,"")).apply(t)}},n={setRoot:function(e){return r.root=e,n},setLoaderTpl:function(e){return r.loaderTpl=e,n},add:function(e){return"object"==typeof e&&e.url&&(e.template||e.templateUrl)?r.routes.push(e):console.log("This route has a problem, it cant be added!",e),n},check:function(e){for(var t,o,a=e||r.getFragment(),l={},c=0;c<r.routes.length;c++){var i=r.routes[c],u=new RegExp("^"+i.url.replace(/(:\w+)/g,"([\\w-]+)")+"$");if(t=a.match(u)){if(t.shift(),o=i.url.match(/(:\w+)/g))for(var s=0;s<o.length;s++)l[o[s].slice(1)]=t[s];return i.options||(i.options={}),i.options.params=l,r.getTemplate(i),n}}return n.navigate(r.root),n},listen:function(){var e,t=null,o=function(){t!==r.getFragment()&&(t=r.getFragment(),n.check(t))};return clearInterval(e),e=setInterval(o,50),n},render:function(t){return e.querySelector(r.el).innerHTML=t,n},navigate:function(e){return e=e?e:"",t.location.href=t.location.href.replace(/#(.*)$/,"#"+e),n}};return n}(document,window);

//Router declaration

  url: "/",
  template: "<h1>Home</h1><p>I am the home template</p>" 
  url: "/user",
  template: '<h1>User</h1><p>Here is the list of users</p> <ul><li><a href="#/user/1">user 1</a><li><li><a href="#/user/2">user 2</a><li></ul>'
  url: "/user/:id",
  template: "<h1>User <% this.params.id %></h1><p>Here is the user's <b><%this.params.id%></b> specific page!</p>" 
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................