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

2015-07-10-kichijoji.pm4_yurui_template

 2015-07-10-kichijoji.pm4_yurui_template

テンプレートとPerlに関するゆるい話

吉祥寺.pm #4

SUZUKI Masashi

July 10, 2015
Tweet

More Decks by SUZUKI Masashi

Other Decks in Programming

Transcript

  1. # データ構造 +{ title => 'なんとかぺーじ', user => +{ name

    => 'かるぱ', age => 18, }, } # 出力 <html> <head title=“なんとかぺーじ”> <body> ドーモ かるぱ=サン </body> # テンプレート <html> <head title=“[% title %]”> <body> ドーモ [% user.name %]=サン </body> テンプレートエンジン=サン 8
  2. Perlのテンプレートエンジン • Text::Xslate • XSで高速 • xslate.org 死んでる? • Template::Toolkit

    (Template Toolkit2) • 広く使われてる • Text::MicroTemplate • コアモジュールのみに依存 
  3. MySQL # generated by mkconf.pl # IP : [% ip

    %] # Memory : [% memsize %]MB #------------------------------------------------ [mysqld] server-id = [% server_id %] [% IF role == 'slave' -%] read_only [%- END %] innodb_buffer_pool_size = [% int(memsize * 0.65) %]M # メモリの65% # snip .., 20
  4. Nginx [%- FOR project IN projects %] upstream app_[% project.name

    %] { [% FOR server IN project.app_servers -%] server [% server %]:[% project.plack_port %]; [% END %] } server { server_name [% FOR domain IN project.domains -%] [% domains %] [% END %] ; location /static/ { root /usr/local/project/[% project.name %]/static; } location / { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_pass http://app_[% projet.name %]; } } [% END %] 22
  5. 日報 #!/bin/bash cat << __EOF__ > $(date +"%Y/%m/%d(%a).md") # $(date

    +"%Y/%m/%d(%a)") 日報 [yesterday](../../$(date --date yesterday +"%Y/%m/%d.md")) / [tomorrow](../../$ (date --date tomorrow +"%Y/%m/%d.md")) ## Todo ## Memo ### Blogged ### Bookmark ## Done ## Doing ## ToDo __EOF__ 24
  6. 日報 #!/bin/bash cat << __EOF__ > $(date +"%Y/%m/%d(%a).md") # $(date

    +"%Y/%m/%d(%a)") 日報 [yesterday](../../$(date --date yesterday +"%Y/%m/%d.md")) / [tomorrow](../../$ (date --date tomorrow +"%Y/%m/%d.md")) ## Todo ## Memo ### Blogged ### Bookmark ## Done ## Doing ## ToDo __EOF__ 27