juan_gandhi: (VP)
Juan-Carlos Gandhi ([personal profile] juan_gandhi) wrote2014-12-05 05:00 pm
Entry tags:

а вот и весь мой рендеринг

  def questionHTML(i: Int, q: String) =
    <span>
      <h3>Question {i+1}</h3>{q}
      <br/><br/><br/><br/><br/><br/>
  </span>

  def variantHTML(v: List[String]) =
    <p style="page-break-after:always;">
      <h1><center>{title}</center></h1>
      {v.zipWithIndex map {case(q,j) => questionHTML(j,q)}}
    </p>

  def html(variants: List[List[String]]) = {
    <html><body>{
      variants map variantHTML
    }</body></html>
  }

[identity profile] Дмитрий Васильев (from livejournal.com) 2014-12-06 06:19 pm (UTC)(link)
render: ->
  div className: 'posts-container',
    div className: 'posts',
      CreateNewPost @props
      for post in @props.posts.items
        Post {post}

[identity profile] juan-gandhi.livejournal.com 2014-12-06 06:51 pm (UTC)(link)
Неплохо смотрится, но не решает мою задачу

[identity profile] Дмитрий Васильев (from livejournal.com) 2014-12-06 08:49 pm (UTC)(link)
Это библиотека react.js и язык coffeescript
questionHTML = (i,q) ->
  span {},
    h3 {}, "Question #{i+1}"
    q
    (br {} for i in [1..3])

variantHTML = (v) ->
  p style: "page-break-after:always",
    h1 {}, center {}, title
    for q, i in v
      questionHTML i, q

html = (variants) -> 
  html {},
    body {}, 
      variants.map variantHTML