defmodule Phoenix.Template.EExEngine do
  alias Phoenix.Template
  @behaviour Phoenix.Template.Engine

  @doc """
  Precompiles the String file_path into a function defintion, using EEx Engine

  For example, given "templates/show.html.eex", returns an AST def of the form:

      def render("show.html", assigns \\ [])

  """
  def precompile(file_path, tpl_name) do
    engine = Template.eex_engine_for_file_ext(Path.extname(tpl_name))
    content = File.read!(file_path)

    quote unquote: true, bind_quoted: [tpl_name: tpl_name, content: content, engine: engine] do
      EEx.function_from_string(:defp, :"#{tpl_name}", content, [:assigns],
                               engine: engine)

      def render(unquote(tpl_name), assigns) do
        unquote(:"#{tpl_name}")(assigns)
      end
    end
  end
end

defmodule Phoenix.Template.EExEngine do
  alias Phoenix.Template
  @behaviour Phoenix.Template.Engine

  @doc """
  Precompiles the String file_path into a function defintion, using EEx Engine

  For example, given "templates/show.html.eex", returns an AST def of the form:

      def render("show.html", assigns \\ [])

  """
  def precompile(file_path, tpl_name) do
    engine = Template.eex_engine_for_file_ext(Path.extname(tpl_name))
    content = read!(file_path)

    quote unquote: true, bind_quoted: [tpl_name: tpl_name, content: content, engine: engine] do
      EEx.function_from_string(:defp, :"#{tpl_name}", content, [:assigns],
                               engine: engine)

      def render(unquote(tpl_name), assigns) do
        unquote(:"#{tpl_name}")(assigns)
      end
    end
  end

  defp read!(file_path) do
    "<% _ = assigns %>" <> File.read!(file_path)
  end
end

Fix unused assigns variable warning for eex templates
Fix unused assigns variable warning for eex templates

milafrerichs/phoenix,doomspork/phoenix,GabrielNicolasAvellaneda/phoenix,DavidAlphaFox/phoenix,nickgartmann/phoenix,FND/phoenix,lono-devices/phoenix,vic/phoenix,Fluxuous/phoenix,phoenixframework/phoenix,nshafer/phoenix,evax/phoenix,ephe-meral/phoenix,robhurring/phoenix,bsodmike/phoenix,Rumel/phoenix,mobileoverlord/phoenix,daytonn/phoenix,KazuCocoa/phoenix,robomc/phoenix,Kosmas/phoenix,tony612/phoenix,optikfluffel/phoenix,manukall/phoenix,eksperimental/phoenix,maxnordlund/phoenix,y-yagi/phoenix,foxnewsnetwork/phoenix,trarbr/phoenix,brucify/phoenix,iStefo/phoenix,0x00evil/phoenix,wsmoak/phoenix,VictorZeng/phoenix,sdnorm/phoenix,optikfluffel/phoenix,nshafer/phoenix,Gazler/phoenix,Joe-noh/phoenix,michalmuskala/phoenix,evax/phoenix,rodrigues/phoenix,ybur-yug/phoenix,lancehalvorsen/phoenix,vic/phoenix,jeffweiss/phoenix,cas27/phoenix,JHKennedy4/phoenix,pap/phoenix,seejee/phoenix,StevenNunez/phoenix,mitchellhenke/phoenix,keathley/phoenix,mschae/phoenix,iguberman/phoenix,kyledecot/phoenix,romul/phoenix,Dahoon/phoenix,begleynk/phoenix,dmarkow/phoenix,kevinold/phoenix,kholbekj/phoenix,bsmr-erlang/phoenix,nshafer/phoenix,phoenixframework/phoenix,0x00evil/phoenix,stefania11/phoenix,hotvulcan/phoenix,marcioj/phoenix,CD1212/phoenix,dmarkow/phoenix,mitchellhenke/phoenix,rafbgarcia/phoenix,mobileoverlord/phoenix,CultivateHQ/phoenix,esbullington/phoenix-1,phoenixframework/phoenix,manukall/phoenix,arthurcolle/phoenix,andrewvy/phoenix,michalmuskala/phoenix,CultivateHQ/phoenix,yonglehou/phoenix,yoavlt/phoenix,xtity/simple_phoenix,Smulligan85/phoenix,ybur-yug/phoenix,lono-devices/phoenix,iStefo/phoenix,bitgamma/phoenix,switchflip/phoenix,omotenko/phoenix_auth,stevedomin/phoenix,doron2402/phoenix,rafbgarcia/phoenix,mvidaurre/phoenix,jwarwick/phoenix,andrewvy/phoenix,sadiqmmm/phoenix,ACPK/phoenix,jasond-s/phoenix,SmartCasual/phoenix,rodrigues/phoenix,omotenko/phoenix_auth,keathley/phoenix,Rumel/phoenix,jwarwick/phoenix,Eventacular/phoenix,korobkov/phoenix,javimolla/phoenix,jamilabreu/phoenix,safi/phoenix,ericmj/phoenix,Smulligan85/phoenix,DavidAlphaFox/phoenix,pap/phoenix,gjaldon/phoenix,gjaldon/phoenix,jeffkreeftmeijer/phoenix,stevedomin/phoenix,lancehalvorsen/phoenix,thegrubbsian/phoenix,beni55/phoenix,rafbgarcia/phoenix,0x00evil/phoenix,hsavit1/phoenix,seejee/phoenix,bdtomlin/phoenix,trarbr/phoenix,Gazler/phoenix,Ben-Evolently/phoenix,Joe-noh/phoenix,jxs/phoenix,henrik/phoenix,bsmr-erlang/phoenix,korobkov/phoenix,wsmoak/phoenix,linearregression/phoenix,greyhwndz/phoenix,mschae/phoenix,scrogson/phoenix,ericmj/phoenix,paulcsmith/phoenix,nicrioux/phoenix,Kosmas/phoenix,cas27/phoenix,jamilabreu/phoenix,mvidaurre/phoenix,ephe-meral/phoenix,elliotcm/phoenix,wicliff/phoenix,justnoxx/phoenix,kidaa/phoenix,ahmetabdi/phoenix,fbjork/phoenix,eksperimental/phoenix,ugisozols/phoenix,optikfluffel/phoenix