Class: Template

Template()

new Template()

Sets up defaults for all the Template methods such as a default template
Source:

Methods

clearCompletedButton(completedTodos) → {string}

Updates the text in the "Clear completed" button.
Parameters:
Name Type Description
completedTodos number The number of completed todos.
Source:
Returns:
String containing the number counted.
Type
string

itemCounter(activeTodos) → {string}

Displays a counter of how many todos are left to complete.
Parameters:
Name Type Description
activeTodos number The number of active todos.
Source:
Returns:
String containing the count.
Type
string

show(data) → {string}

Creates an li HTML string and returns it for placement in your app. NOTE: In real life you should be using a templating engine such as Mustache or Handlebars, however, this is a vanilla JS example.
Parameters:
Name Type Description
data object The object containing keys you want to find in the template to replace.
Source:
Returns:
HTML String of an
  • element
  • Type
    string
    Example
    view.show({
    	id: 1,
    	title: "Hello World",
    	completed: 0,
    });