Pro Yearly is on sale from $80 to $50! »

Xslate振り返り

9278c3a06b8d8752fb913dea93f959c1?s=47 FUJI Goro
October 17, 2014

 Xslate振り返り

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

9278c3a06b8d8752fb913dea93f959c1?s=128

FUJI Goro

October 17, 2014
Tweet

Transcript

  1. Xslate։ൃͷৼΓฦΓ Template Engine Night 2014-10-17 by gfx (CPAN:GFUJI)

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

    • HTMLΑΓ΋Androidͷlayout XMLͷ΄͏Λ୔ࢁॻ͍ ͯ·͢ • Xslate͸2010೥4݄ʹ։ൃͯ͠2011೥1݄ʹ1.0
  3. http://xslate.org/ https://github.com/xslate

  4. arity

  5. Introduction to Xslate • Xslate: Perl࠷଎ͷςϯϓϨʔτΤϯδϯ • ʮςϯϓϨʔτΤϯδϯͷ࣮૷͸ʰ଎౓ʱͱʰػೳʱ ͷτϨʔυΦϑ͕͋Δʯͱ͍͏ݴઆΛ൱ఆͨ͠ʂ •

    ࣮ߦΤϯδϯ͸CͰ࣮૷ͨ͠Ծ૝Ϛγϯ • DTC: Direct Threaded Code • YARV ManiacsͱCRubyΛࢀߟʹͨ͠
  6. ࢀߟ: XslateҎલͷ࣌୅ • ߴ଎ • HTML::Template::Pro, Text::ClearSilver • ߴػೳ •

    Template-Toolkit, Text::MicroTemplate
  7. )FMMP OBNF "45 0QDPEF4FRVFODF %5$ < <MJUFSBM l)FMMP l> 

    <QSJOU lOBNFz> > QBSTF DPNQJMF BTTFNCMF
  8. Virtual Machine (written in C)

  9. Template Syntax (“Kolon”)

  10. Xslateͷಛ௃ • छྨ • ൚༻ɾಠࣗݴޠܕʢSmarty, Mustache) • ࢀߟ: ൚༻ɾϗετݴޠܕʢerb, JSPʣ,

    HAMLܕ (haml, Jade), XMLܕ (Thymeleaf, Genshi) • ॏ఺ • ߴػೳ & ߴ଎ ʢ͍͍ͩͨओཁͳػೳ͸͋ͬͯ଎͍ʣ • ࢀߟ: Τϯδϯͷอकੑ, ςϯϓϨʔτϑΝΠϧͷอकੑ, ଞͷݴޠ͔Βͷར༻
  11. ৼΓฦΓ Keep / Problem / Try

  12. Keep - Α͔ͬͨ͜ͱ • σϑΝΫτͩͬͨTemplate-Toolkitͷ100ഒߴ଎ • ஋ͷܕͰHTML escapeͷཁɾෆཁΛܾఆ͢Δ • PSGI͚ͩΛߟ͑ͯೖग़ྗΛ୯७ʹͨ͠

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

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

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

    ͕ى͖͕͕ͪͩ࠶ར༻Ͱ͖ΔՄೳੑ͸ߴ͍ • ౉ͤΔσʔλ΋JSONʹ੍ݶͤ͟ΔΛ͑ͳ͍ • རศੑͱͷτϨʔυΦϑ͕ͩݕ౼ͷՁ஋͸͋Δ
  16. ςϯϓϨʔτͷछྨ • ൚༻ܕ͸HTMLͷग़ྗҎ֎ʹ΋࢖͑ΔͷͰඞਢ • hamlܕ͸ॻ͘ͷָ͕ͳ൓໘ɺֶशίετ͕ߴ ͍ɻه๏΋౷Ұ͞Ε͓ͯΒͣա౉ظͳײ͡ • XMLܕͷϝϦοτ͸Α͘Θ͔Βͳ͍ • SࣜͰॻ͘ͷҙ֎ͱѱ͘ͳ͍Μ͡Όͳ͍͔

  17. hamlͷޭࡑ • %ul • %li • - if expr •

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

    <: $foo // “bar” :> ͸$foo͕ۭͰ͋Ε͹barʹͳΔ • <: f($foo) :> ͜ͷϢʔβʔఆٛؔ਺ͱΈΒΕΔf()͸ଥ౰͔ʁ • ͜ͷνΣοΫΛ੩తʹ͢Δͷ͸೉͍͠ • ఆٛͷΈΛॻ͍ͨσʔλ = IDL͕ඞཁ
  19. That’s all. ! ࢀߟ: https://gist.github.com/ tokuhirom/61f5e20cf759706ca3c9