Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

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


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


 <link rel="stylesheet" href="">
<div id="todoapp"></div>

<footer id="info">
  <p>Double-click to edit a todo</p>
  <p>Created by @leeluolee</p>
    Part of
    <a href="">TodoMVC</a>
<script type='template/regular' id='todo'>
<li  r-class={ {'completed': todo.completed, 'editing': todo.editing} }>
  <div class="view">
    <input class="toggle" type="checkbox" r-model={ todo.completed }>  
    <label on-dblclick={todo.editing = true}>{ todo.description }</label>
    <button on-click="remove" class="destroy"></button>
  <input id="edit" class="edit"on-enter={ todo.editing = false } r-model={todo.description} autofocus>

<script type='template/regular' id='todomvc'>
  <input id="new-todo" on-enter={ this.newTodo(editTodo) } placeholder="What needs to be done?" r-model={ editTodo }>
{#if !!todos.length}
<section id="main">

  <input id="toggle-all" type="checkbox" name='toggle' r-model='allCompleted'>
  <label for="toggle-all">Mark all as complete</label>
  <ul id="todo-list">
    {#list this.getList(filter) as todo}
    <todo todo={todo} on-remove={todos.splice(todo_index,1)} ></todo>
<footer id="footer">
  <span id="todo-count"> <strong>{ activeLength }</strong>
    { activeLength === 1 ? 'item' : 'items' } left
  <ul id="filters">
      <a class="{ filter === 'all'? 'selected' : '' }"  href="javascript:;" on-click={filter='all'}>All</a>
      <a class="{ filter === 'active'? 'selected' : '' }" href='javascript:;' on-click={filter = 'active'}>Active</a>
      <a class="{ filter === 'completed'? 'selected' : '' }" href="javascript:;" on-click={filter = 'completed'}>Completed</a>
  {#if completedLength}
  <button id="clear-completed" on-click={this.clearCompleted()} >Clear completed ({ completedLength })</button>
<!-- 引入regularjs -->
<script src=""></script>






                //Define Custom Event enter
Regular.event('enter', function(element, fire){
  Regular.dom.on(element, 'keypress', function(ev){
    if(ev.which === 13) fire(ev)

var Todo = Regular.extend({
  name: "todo",
  template: "#todo"

var TodoMVC = Regular.extend({
    template: '#todomvc', // id | template string | preparsed ast
    // get the list;
      computed: {
      completedLength: "this.getList('completed').length",
      activeLength: "this.getList('active').length",
      allCompleted: {
        get: function(){
          return === this.getList('completed').length
        set: function(sign){
            item.completed = sign;
    getList: function(filter){
      if(!filter || filter === 'all') return;
      else return{
        return filter === 'completed'? item.completed : !item.completed;
    // toggle all todo's completed state
    toggleAll: function(sign){{
        return item.completed = !sign;
    // clear all compleled
    clearCompleted: function(){ ={
        return !item.completed
    // create a new todo
    newTodo: function(editTodo){
      var data =;
      data.todos.unshift({description: editTodo});
      data.editTodo = "";
var todos = [
    {completed: true, description: "sleep" },
    {completed: false, description: "work" }
var app = new TodoMVC({
    data: {todos: todos}