<commit_before>Monkey.registerView 'post', '''
  div[id="monkey"]
    h1 title
    p body
    h3 "Comments (" commentCount ")"
    form[submit=postComment]
      p
        textarea[change=commentEdited]
      p
        input[type="submit" value="Post"]
    ul
      - collection comments
        - view comment
'''

Monkey.registerView 'comment', '''
  li
    p body
    p
      a[click=highlight href="#"] "Highlight"
'''

class Post extends Monkey.Model
  @property 'title'
  @property 'body'
  @property 'commentCount', dependsOn: 'comments', get: -> @comments.length
  @collection 'comments'

class Comment extends Monkey.Model
  @property 'body'

class PostController
  postComment: (event) ->
    @model.comments.push(@newComment)
    event.preventDefault()

  commentEdited: (event) ->
    @newComment = { body: event.target.value }

class CommentController
  highlight: ->
    @view.style.backgroundColor = 'red'

Monkey.registerController 'post', PostController
Monkey.registerController 'comment', CommentController

window.aPost = new Post()

aPost.comments = [{body: 'test'}, {body: 'another'}]

window.onload = ->
  view = Monkey.render('post', aPost)
  sandbox = document.body.appendChild(view)<commit_msg>Use multi property set in example<commit_after>Monkey.registerView 'post', '''
  div[id="monkey"]
    h1 title
    p body
    h3 "Comments (" commentCount ")"
    form[submit=postComment]
      p
        textarea[change=commentEdited]
      p
        input[type="submit" value="Post"]
    ul
      - collection comments
        - view comment
'''

Monkey.registerView 'comment', '''
  li
    p body
    p
      a[click=highlight href="#"] "Highlight"
'''

class Post extends Monkey.Model
  @property 'title'
  @property 'body'
  @property 'commentCount', dependsOn: 'comments', get: -> @comments.length
  @collection 'comments'

class Comment extends Monkey.Model
  @property 'body'

class PostController
  postComment: (event) ->
    @model.comments.push(@newComment)
    event.preventDefault()

  commentEdited: (event) ->
    @newComment = { body: event.target.value }

class CommentController
  highlight: ->
    @view.style.backgroundColor = 'red'

Monkey.registerController 'post', PostController
Monkey.registerController 'comment', CommentController

window.aPost = new Post()

aPost.set
  title: 'Monkey.js released!'
  body: 'New contender in the JS framework wars!'
  comments: [{body: 'This is cool'}, {body: 'I hate it'}]

window.onload = ->
  document.body.appendChild Monkey.render('post', aPost)
{'fraction_non_alphanumeric': 0.13156854998024498, 'fraction_numerical': 0.0015804030027657052, 'mean_word_length': 3.6373626373626373, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1175995', 'n_tokens_mistral': 777, 'n_tokens_neox': 765, 'n_words': 194}