Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Xslate振り返り

FUJI Goro
October 17, 2014

 Xslate振り返り

Template Engine Night 2014/10/17 の資料です

FUJI Goro

October 17, 2014
Tweet

More Decks by FUJI Goro

Other Decks in Technology

Transcript

  1. ࣗݾ঺հ • gfx • ϞόΠϧΞϓϦΤϯδχΞ • Android / iOS ༻ͷࣾ಺ϥΠϒϥϦ։ൃ͕ओ

    • HTMLΑΓ΋Androidͷlayout XMLͷ΄͏Λ୔ࢁॻ͍ ͯ·͢ • Xslate͸2010೥4݄ʹ։ൃͯ͠2011೥1݄ʹ1.0
  2. )FMMP OBNF "45 0QDPEF4FRVFODF %5$ < <MJUFSBM l)FMMP l> 

    <QSJOU lOBNFz> > QBSTF DPNQJMF BTTFNCMF
  3. Xslateͷಛ௃ • छྨ • ൚༻ɾಠࣗݴޠܕʢSmarty, Mustache) • ࢀߟ: ൚༻ɾϗετݴޠܕʢerb, JSPʣ,

    HAMLܕ (haml, Jade), XMLܕ (Thymeleaf, Genshi) • ॏ఺ • ߴػೳ & ߴ଎ ʢ͍͍ͩͨओཁͳػೳ͸͋ͬͯ଎͍ʣ • ࢀߟ: Τϯδϯͷอकੑ, ςϯϓϨʔτϑΝΠϧͷอकੑ, ଞͷݴޠ͔Βͷར༻
  4. Keep - Α͔ͬͨ͜ͱ • σϑΝΫτͩͬͨTemplate-Toolkitͷ100ഒߴ଎ • ஋ͷܕͰHTML escapeͷཁɾෆཁΛܾఆ͢Δ • PSGI͚ͩΛߟ͑ͯೖग़ྗΛ୯७ʹͨ͠

    • ύʔαɾίϯύΠϥɾVMΛ෼཭͍͓͔ͯͨ͛͠Ͱ੩తղੳπʔϧ Λ࡞Δ༨஍͕͋ͬͨ • Locale::Maketext::Extract::Plugin::Xslate • جຊػೳҎ֎͸͢΂ͯϢʔβʔఆٛؔ਺Ͱఏڙͱ͍͏ͷ΋Α͔ͬͨ
  5. Problem - ѱ͔ͬͨ͜ͱ • ଎౓ʹͩ͜ΘΓ࣮͗ͯ͢૷͕೉ղʹͳͬͨ • CʹΑΔͩ͜ΘΓͷVM, ෳࡶ͗͢ΔΩϟογϡγεςϜ… • ࣮༻Ϩϕϧͷ଎౓͕͋Ε͹ɺ࣍ʹॏཁͳͷ͸อकੑ

    • ಈతܕ෇͖ݴޠతͳܽ఺ • ͋Δύϥϝʔλ͕ʮ೚ҙʯͳͷ͔ʮඞਢʯͳͷ͔Λهड़Ͱ͖ͳ͍ • ΠϯΫϧʔυͰม਺ΛೝΊΔʢ<: include $file :> ʣඞཁ͸ຊ౰ʹඞ ཁ͔ͩͬͨ • ։ൃऀ͕΢Σϒ։ൃΛ͠ͳ͔ͬͨʢ࢓ࣄͰ࢖͏ͱࢥͬͨΒ࢖Θͳ͔ͬͨʣ
  6. Try - ະདྷͷςϯϓϨʔτΤϯδϯ • ७ਮʹϗετݴޠͰ࣮૷͢Δ or JavaScriptͰ࣮૷ • ੩తղੳΛ༰қʹͯ͠πʔϧνΣΠϯΛ๛෋ʹ •

    ςϯϓϨʔτϑΝΠϧͷؔ܎Λநग़͢Δπʔϧ • Ͳ͏͍͏ύϥϝʔλΛͱΔ͔Λநग़͢Δπʔϧ • ϓϩϑΝΠϥ͕΄͍͠ • ͍ͣΕʹͤΑςϯϓϨʔτݴޠ͸JSͷαϒηοτͰΑ͍
  7. ࣮૷ݴޠ • ϗετݴޠͰ࣮૷͢Δͱϝϯς͠΍͍͢ • Keep It Simple, Stupid! • JavaScriptͰ࣮૷͢ΔͱϒϦοδ෦෼Ͱτϥϒϧ

    ͕ى͖͕͕ͪͩ࠶ར༻Ͱ͖ΔՄೳੑ͸ߴ͍ • ౉ͤΔσʔλ΋JSONʹ੍ݶͤ͟ΔΛ͑ͳ͍ • རศੑͱͷτϨʔυΦϑ͕ͩݕ౼ͷՁ஋͸͋Δ
  8. hamlͷޭࡑ • %ul • %li • - if expr •

    Hello, world # ΠϯσϯτϨϕϧ͸ʁ • ࣮૷͕buggy & slowͰΞϨ͗͢Δ
  9. ੩తղੳ • ϓϩάϥϜΛ࣮ߦͤͣʹɺߏจˍincludeͷଥ౰ੑ&ύϥϝʔλͷ ଥ౰ੑΛνΣοΫ͍ͨ͠ • <: $foo :> ͕ۭʹͳΔͷ͸ϩδοΫΤϥʔ •

    <: $foo // “bar” :> ͸$foo͕ۭͰ͋Ε͹barʹͳΔ • <: f($foo) :> ͜ͷϢʔβʔఆٛؔ਺ͱΈΒΕΔf()͸ଥ౰͔ʁ • ͜ͷνΣοΫΛ੩తʹ͢Δͷ͸೉͍͠ • ఆٛͷΈΛॻ͍ͨσʔλ = IDL͕ඞཁ