简体   繁体   English

如何在我的 Elixir Phoenix LiveView 应用程序 header 中混合实时和“死”内容?

[英]How do I mix live and "dead" content in my Elixir Phoenix LiveView app header?

I changed my root.html.heex file to look like this:我将 root.html.heex 文件更改为如下所示:

<!DOCTYPE html>
<html lang="en">
  <head>
    ...
  </head>
  <body>
    <%= @inner_content %>
  </body>
</html>

And moved the <header> element to be duplicated in app.html.heex :并将<header>元素移动到app.html.heex中:

<header>
  <section class="container w-full m-5 p-3 bg-blue-200 text-blue-600 text-5xl font-bold">
    <div class="text-2xl">
      <a href="/">
        <img class="float-left mt-1"
          src={Routes.static_path(@conn, "/images/logo.png")} alt="LOGO"/>
        <span class="flex text-4xl hover:text-blue-800">
          <span class="font-medium nomargin">WEBSITE</span>
        </span>
      </a>
      <span class="float-right flex -mt-8 font-normal">
        <nav role="navigation">
          <%= render "_user_menu.html", assigns %>
        </nav>
      </span>
    </div>
  </section>
</header>
<main class="container">
  <p class="alert alert-info" role="alert"><%= get_flash(@conn, :info) %></p>
  <p class="alert alert-danger" role="alert"><%= get_flash(@conn, :error) %></p>
  <%= @inner_content %>
</main>

...and in live.html.heex . ...并在live.html.heex中。

But I can't render "_user_menu.html" in live.html.heex because (of course) it uses @current_user .但我无法在live.html.heex中呈现“_user_menu.html”,因为(当然)它使用@current_user

Is there a trick that allows me to somehow have live content on the float-left side of the header and the "_user_menu.html" fragment on the float-right side?有没有什么技巧可以让我以某种方式在 header 的浮动左侧显示实时内容,在浮动右侧显示“_user_menu.html”片段?

Generally if you need to mix "Live" and "Dead" views/templates, there is live_render/3 documented here .通常,如果您需要混合“Live”和“Dead”视图/模板,这里有live_render/3 文档 Been there, seen that [working];-)去过那里,看到那个[工作];-)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Azure Function应用中设置“ X-Content-Type-Options”标头? - How do I set the 'X-Content-Type-Options' header in an Azure Function App? 如何在我的 Azure 应用服务 (Linux) 中增加 HTTP 请求 header 的大小 - How do I increase the size of HTTP request header in my Azure App Service (Linux) 如何更改curl内容搜寻器的标题位置 - How do I change header location of curl content scraper 当标头长度超过约 4000 个字符时,Elixir Phoenix 应用程序返回 431 错误 - Elixir Phoenix app returning 431 error when headers are longer than ~4000 chars 在我的网站发出的请求中,如何控制HTTP HOST标头的内容? - How can I control the content of the HTTP HOST header in requests issued from my website? 如何为不同的浏览器设置正确的Content-Type标头? - How do I set the correct Content-Type header for the different browsers? 如何阅读内容处置标题的内容? - How can I read the content of the content-disposition header? 如何阻止sinatra重新编写标题名称? - how do I stop sinatra from re-writing my header names? 如何删除或更改服务器上运行的软件的值(服务器头)? - How do I remove or change the value of the software being run on my server (server header)? 在S3服务器上上传时,如何在C#中的HttpRequestMessage.Headers中添加content-md5标头? - How do i add a content-md5 header to HttpRequestMessage.Headers in C# when i'm uploading on S3 server?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM