Template - RomainValy/ToDoMVC-OpenclassRoom-project GitHub Wiki

Table of Contents

Template

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

escapeHtmlChar

Parameters

  • chr Array get the escape Html character

defaultTemplate

Parameters

  • defaultTemplate string push a default template of a TODO on the DOM

show

Creates an 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

  • data Object The object containing keys you want to find in the template to replace.

Examples

view.show({
id: 1,
title: "Hello World",
completed: 0,
});

Returns string HTML String of an element

itemCounter

Displays a counter of how many to dos are left to complete

Parameters

  • activeTodos number The number of active todos.

Returns string String containing the count

clearCompletedButton

Updates the text within the "Clear completed" button

Parameters

  • completedTodos Number The number of completed todos.

Returns string String containing the count

app

Export to window