Phoenix에서 haml 템플릿 사용
개요
phoenix_haml 설치
 phoenix_haml | Github 을 사용합니다.
mix.exs
  defp deps do
    [
      {:phoenix, "~> 1.3.0-rc"},
      {:phoenix_pubsub, "~> 1.0"},
      {:phoenix_ecto, "~> 3.2"},
      {:postgrex, ">= 0.0.0"},
      {:phoenix_html, "~> 2.10"},
      {:phoenix_live_reload, "~> 1.0", only: :dev},
      {:gettext, "~> 0.11"},
      {:cowboy, "~> 1.0"},
+     {:phoenix_haml, "~> 0.2"}
    ]
  end
$ mix deps.get
 템플릿 엔진 변경
config/config.exs
+ config :phoenix, :template_engines, haml: PhoenixHaml.Engine
live reload 하기 위해 config/dev.exs 를 편집합니다.
config/dev.exs
config :haml, Haml.Endpoint,
  live_reload: [
    patterns: [
      ~r{priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$},
      ~r{priv/gettext/.*(po)$},
      ~r{web/views/.*(ex)$},
-     ~r{web/templates/.*(eex)$}
+     ~r{web/templates/.*(eex|haml)$}
    ]
  ]
이상을 설정하면 움직입니다.
 샘플
web/controllers/page_controller.ex
defmodule Haml.PageController do
  use Haml.Web, :controller
  def index(conn, _params) do
-  render conn, "index.html"
+  render conn, "index.html", name: "テスト"
  end
end
web/templates/page/index.html.haml
%h1
  = @name
아래와 같이 표시되면 성공입니다.
 
                
                    
        
    
    
    
    
    
                
                
                
                
                    
                        
                            
                            
                            Reference
                            
                            이 문제에 관하여(Phoenix에서 haml 템플릿 사용), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
                                
                                https://qiita.com/cohki0305/items/c256ff432fe5e58c471e
                            
                            
                            
                                텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                            
                            
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                            
                            
                        
                    
                
                
                
            
  defp deps do
    [
      {:phoenix, "~> 1.3.0-rc"},
      {:phoenix_pubsub, "~> 1.0"},
      {:phoenix_ecto, "~> 3.2"},
      {:postgrex, ">= 0.0.0"},
      {:phoenix_html, "~> 2.10"},
      {:phoenix_live_reload, "~> 1.0", only: :dev},
      {:gettext, "~> 0.11"},
      {:cowboy, "~> 1.0"},
+     {:phoenix_haml, "~> 0.2"}
    ]
  end
$ mix deps.get
config/config.exs
+ config :phoenix, :template_engines, haml: PhoenixHaml.Engine
live reload 하기 위해
config/dev.exs 를 편집합니다.config/dev.exs
config :haml, Haml.Endpoint,
  live_reload: [
    patterns: [
      ~r{priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$},
      ~r{priv/gettext/.*(po)$},
      ~r{web/views/.*(ex)$},
-     ~r{web/templates/.*(eex)$}
+     ~r{web/templates/.*(eex|haml)$}
    ]
  ]
이상을 설정하면 움직입니다.
샘플
web/controllers/page_controller.ex
defmodule Haml.PageController do
  use Haml.Web, :controller
  def index(conn, _params) do
-  render conn, "index.html"
+  render conn, "index.html", name: "テスト"
  end
end
web/templates/page/index.html.haml
%h1
  = @name
아래와 같이 표시되면 성공입니다.
 
                
                    
        
    
    
    
    
    
                
                
                
                
                    
                        
                            
                            
                            Reference
                            
                            이 문제에 관하여(Phoenix에서 haml 템플릿 사용), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
                                
                                https://qiita.com/cohki0305/items/c256ff432fe5e58c471e
                            
                            
                            
                                텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                            
                            
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                            
                            
                        
                    
                
                
                
            
defmodule Haml.PageController do
  use Haml.Web, :controller
  def index(conn, _params) do
-  render conn, "index.html"
+  render conn, "index.html", name: "テスト"
  end
end
%h1
  = @name
Reference
이 문제에 관하여(Phoenix에서 haml 템플릿 사용), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/cohki0305/items/c256ff432fe5e58c471e텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)