<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="99694" data-post-id="99694">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tmbb" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tmbb
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="OvermindDL1" data-post="50" data-topic="16533">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/overminddl1/48/2677_2.png" class="avatar"> OvermindDL1:</div>
<blockquote>
<p>Although merging it into Phoenix as it’s own EEx replacement engine for specific html work could be quite interesting…</p>
</blockquote>
</aside>
<p>This engine is already compatible with the default Phoenix engine. It doesn’t generate the same iolists, but it should return the same binary output (needs testing when I have the time for it, of course, but it’s written to be compatible.</p>
<p>All Phonix widgets can be used in this template, it’s just that they’re not optimized. To optimize the widget’s output (merge static parts together, etc), the widgets must be implemented as macros which can expand into something sensible depending on whether the AST given as argument is dynamic or static.</p>
<p>EDIT: which means that merging this into Phoenix is only worth it if the default widgets are implemented as macros.</p>
<p>Depending on how the user used them, they might be indistinguishable, but things won’t be backward comptible. You can’t use macros as arguments to higher order functions. For example: <code>Enum.map(&amp;macro/1, list)</code> doesn’t really work like the user expects.</p>
<p>These comptibility breaks are probably a dealbreaker for it to be merged into Phoenix.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="99694" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/phoenixundeadview-lets-discuss-optimization-possibilities-for-something-like-phoenix-liveview/16533/52">Post #51</a>
	                </div>
	            </div>
              <div id="likers-container-99694" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="99694"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #51"></div>
  </section>
</div>
    <div class="postbit" id="99696" data-post-id="99696">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tmbb" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tmbb
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I have to find out how easy it is to replace the default EEx engine in a phoenix application. I know it’s relatively simple to add new engines for new filetypes, but I wonder if it is easy to override the dafault one. If so, using Undead templates would be as simple as flipping a config option and importing the right widgets.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="99696" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/phoenixundeadview-lets-discuss-optimization-possibilities-for-something-like-phoenix-liveview/16533/53">Post #52</a>
	                </div>
	            </div>
              <div id="likers-container-99696" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="99696"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #52"></div>
  </section>
</div>
    <div class="postbit" id="99709" data-post-id="99709">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="OvermindDL1" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/OvermindDL1/120/2677_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  OvermindDL1
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="tmbb" data-post="51" data-topic="16533">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/t/77aa72/48.png" class="avatar"> tmbb:</div>
<blockquote>
<p>I can generate any binary. This engine doesn’t care about HTML, and I don’t intend to make it HTML specific.</p>
</blockquote>
</aside>
<p>Well I mean for the <code>PhoenixUndeadView</code> part, not just the EEx engine.  <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<aside class="quote no-group" data-username="tmbb" data-post="52" data-topic="16533">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/t/77aa72/48.png" class="avatar"> tmbb:</div>
<blockquote>
<p>EDIT: which means that merging this into Phoenix is only worth it if the default widgets are implemented as macros.</p>
</blockquote>
</aside>
<p>Yeah it will require the redesign of phoenix_html by far.</p>
<aside class="quote no-group" data-username="tmbb" data-post="53" data-topic="16533" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/t/77aa72/48.png" class="avatar"> tmbb:</div>
<blockquote>
<p>I have to find out how easy it is to replace the default EEx engine in a phoenix application. I know it’s relatively simple to add new engines for new filetypes, but I wonder if it is easy to override the dafault one. If so, using Undead templates would be as simple as flipping a config option and importing the right widgets.</p>
</blockquote>
</aside>
<p>Well drab did it by adding a new extension handler (`*.drab instead of *.eex), maybe you could do it by replacing an existing extension?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="99709" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/phoenixundeadview-lets-discuss-optimization-possibilities-for-something-like-phoenix-liveview/16533/54">Post #53</a>
	                </div>
	            </div>
              <div id="likers-container-99709" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="99709"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #53"></div>
  </section>
</div>
    <div class="postbit" id="99715" data-post-id="99715">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tmbb" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tmbb
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="OvermindDL1" data-post="54" data-topic="16533">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/overminddl1/48/2677_2.png" class="avatar"> OvermindDL1:</div>
<blockquote>
<p>Yeah it will require the redesign of phoenix_html by far.</p>
</blockquote>
</aside>
<p>That’s not too hard. <code>phoenix_html</code> is not that big. It’s more docstrings than actual code. The problems is that the widgets will have to become macros, which isn’t 100% backward compatible, and I don’t even know if the performance impact is that</p>
<p>Actually, my (incomplete) version of phoenix_html is much bigger because I have to analyze a bunch of extra things at compile time.</p>
<p>EDIT: <a class="mention" href="/u/overminddl1" rel="nofollow">@OvermindDL1</a>, you might find it interesting to look at the code inside the <code>lib/phoenix_undead_view/template/widgets/</code> directory. It’s what I imagine Spirit’s source might look like (I don’t know enough C++ template language to take a look myself).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="99715" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/phoenixundeadview-lets-discuss-optimization-possibilities-for-something-like-phoenix-liveview/16533/55">Post #54</a>
	                </div>
	            </div>
              <div id="likers-container-99715" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="99715"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #54"></div>
  </section>
</div>
    <div class="postbit" id="99832" data-post-id="99832">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="OvermindDL1" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/OvermindDL1/120/2677_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  OvermindDL1
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="tmbb" data-post="55" data-topic="16533">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/t/77aa72/48.png" class="avatar"> tmbb:</div>
<blockquote>
<p>(I don’t know enough C++ template language to take a look myself)</p>
</blockquote>
</aside>
<p>You want to see some C++ template code?  Take a look at:<br>
<a href="https://github.com/boostorg/spirit/blob/develop/include/boost/spirit/home/qi/numeric/uint.hpp" class="onebox" target="_blank" rel="noopener nofollow ugc">https://github.com/boostorg/spirit/blob/develop/include/boost/spirit/home/qi/numeric/uint.hpp</a><br>
That entire mass-of-horror-of-a-file is both the fastest uint parser in the world (same with basically all the other parsers in spirit) because it creates optimized assembly for every tiny little possible variant of unsigned integral parsing (you should see the <code>real</code> typ eparser!) that you could ever need, and that entire file I replicate (significantly less efficiently) in ExSpirit at:<br>
<a href="https://github.com/OvermindDL1/ex_spirit/blob/master/lib/ex_spirit/parser/text.ex#L311-L358" class="onebox" target="_blank" rel="noopener nofollow ugc">https://github.com/OvermindDL1/ex_spirit/blob/master/lib/ex_spirit/parser/text.ex#L311-L358</a></p>
<p>C++ Templates are magic and wonderful, but their syntax is like a combination of Haskell, lambda calculus, and a bit of lovecraftian horror.  Nothing you could do in Elixir would ever look as abhorrant.  ^.^</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="99832" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/phoenixundeadview-lets-discuss-optimization-possibilities-for-something-like-phoenix-liveview/16533/56">Post #55</a>
	                </div>
	            </div>
              <div id="likers-container-99832" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="99832"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #55"></div>
  </section>
</div>
    <div class="postbit" id="99841" data-post-id="99841">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tmbb" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tmbb
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="OvermindDL1" data-post="56" data-topic="16533">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/overminddl1/48/2677_2.png" class="avatar"> OvermindDL1:</div>
<blockquote>
<p>Nothing you could do in Elixir would ever look as abhorrant. ^.^</p>
</blockquote>
</aside>
<p>What i’m doing is not abhorrant, it’s just that I’m obsessively traversing the AST of the arguments of the macro to separate the static frol the dynamic parts. I’s nothing especially bad, it’s just case analysis all the way down</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="99841" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/phoenixundeadview-lets-discuss-optimization-possibilities-for-something-like-phoenix-liveview/16533/57">Post #56</a>
	                </div>
	            </div>
              <div id="likers-container-99841" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="99841"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #56"></div>
  </section>
</div>
    <div class="postbit" id="100297" data-post-id="100297">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tmbb" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tmbb
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I’m now compiling the template into a DOM node and some JSON. The JSON contains the static parts, which will be merged with the dynamic parts sent by the server to build the DOM node. An example:</p>
<pre><code class="lang-plaintext">  &lt;% a = 2 %&gt;
  &lt;% fixed = a %&gt;
  Static part #1

  &lt;%/ fixed %&gt;

  &lt;%= if a &gt; 1 do %&gt;
    &lt;%= a %&gt;
  &lt;% else %&gt;
    Nope
  &lt;% end %&gt;

  Static part #2
</code></pre>
<p>Which compiles to:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">_ = assigns
element_id = Integer.to_string(:rand.uniform(4_294_967_296), 32)
a = 2
fixed = a

tmp_4_fixed =
  case(fixed) do
    {:safe, data} -&gt;
      data

    bin when is_binary(bin) -&gt;
      Plug.HTML.html_escape_to_iodata(bin)

    other -&gt;
      Phoenix.HTML.Safe.to_iodata(other)
  end

tmp_6_dynamic =
  case(
    case(a &gt; 1) do
      x when :erlang.orelse(:erlang."=:="(x, nil), :erlang."=:="(x, false)) -&gt;
        {:safe, ["\n  Nope\n"]}

      _ -&gt;
        tmp_2_2_dynamic =
          case(a) do
            {:safe, data} -&gt;
              data

            bin when is_binary(bin) -&gt;
              Plug.HTML.html_escape_to_iodata(bin)

            other -&gt;
              Phoenix.HTML.Safe.to_iodata(other)
          end

        {:safe, ["\n  ", tmp_2_2_dynamic, "\n"]}
    end
  ) do
    {:safe, data} -&gt;
      data

    bin when is_binary(bin) -&gt;
      Plug.HTML.html_escape_to_iodata(bin)

    other -&gt;
      Phoenix.HTML.Safe.to_iodata(other)
  end

{:safe,
 [
   "&lt;span id=\"",
   element_id,
   "\"&gt;\n\nStatic part #1\n\n",
   tmp_4_fixed,
   "\n\n",
   tmp_6_dynamic,
   "\n\nStatic part #2\n&lt;/span&gt;\n\n&lt;script type=\"application/json\" undead-id=\"",
   element_id,
   "\"&gt;\n[\n  \"\",\n  \"\\n\\nStatic part #1\\n\\n",
   Phoenix.HTML.escape_javascript(tmp_4_fixed),
   "\\n\\n\",\n  \"\\n\\nStatic part #2\\n\"\n]\n&lt;/script&gt;"
 ]}
</code></pre>
<p>The expression above is complex, but it’s not that hard to follow. It’s a span tag containing a DOM node (actually plaintext, but that shouldn’t be a problem for something like morphdom) followed by a script tag that contains some JSON.</p>
<p>Note that:</p>
<ol>
<li>I generate a unique ID for the DOM node. Maybe it should be possible to specify the element ID in the assigns?</li>
<li>I start with <code>_ = assigns</code> so that writing a template that doesn’t use the assigns doesn’t raise a warning.</li>
</ol>
<p>The above will render into the following (the assigns don’t matter because it’s independent from the assigns):</p>
<pre><code class="lang-plaintext">&lt;span id="1IE7FC5"&gt;

Static part #1

2


  2


Static part #2
&lt;/span&gt;

&lt;script type="application/json" undead-id="1IE7FC5"&gt;
[
  "",
  "\n\nStatic part #1\n\n2\n\n",
  "\n\nStatic part #2\n"
]
&lt;/script&gt;
</code></pre>
<p>The code that does the above is already available, but it’s a mess. I’ll refactor it (and delete dead code) ASAP.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="100297" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/phoenixundeadview-lets-discuss-optimization-possibilities-for-something-like-phoenix-liveview/16533/58">Post #57</a>
	                </div>
	            </div>
              <div id="likers-container-100297" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="100297"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #57"></div>
  </section>
</div>
    <div class="postbit" id="100299" data-post-id="100299">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tmbb" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tmbb
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>It looks like it should be easy to ug this into a Drab commander (probably a shared commander). Drab already does a lot of yhe grunt work of bridging the world of HTTP requests and websockets, so it’s probably easy to use to handle the undead templates.</p>
<p><a class="mention" href="/u/grych" rel="nofollow">@grych</a> might be interested in the last post in this series.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="100299" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/phoenixundeadview-lets-discuss-optimization-possibilities-for-something-like-phoenix-liveview/16533/59">Post #58</a>
	                </div>
	            </div>
              <div id="likers-container-100299" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="100299"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #58"></div>
  </section>
</div>
    <div class="postbit" id="100363" data-post-id="100363">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tmbb" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tmbb
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>As I’ve said before, these templates should be comparible with Phoenix (only more optimized). I’d like to benchmark compilation time and runtime performance of these templates agains the default engine. But I really don’t know what the relevant metrics are. The time it takes to render the template into an iolist is the obvious one. But I wonder if there is a way to measure how long it takes to send the bytes over a socket, and whether it is relevant.</p>
<p>Ultimately, I’d like to integrate this with Phoenix (the static part only). Is this something the Phoenix team would be ok with? It’s probably only worth it if it’s faster <strong>and</strong> if some HTML function helpers in <code>phoenix_html</code> are replaced by mostly backward compatible macros. Otherwise I can’t statically expand the widgets at compile time and make use of main optimization, which is to merge adjacent static segments together. If the phoenix team doesn’t agree with these changes, I’ll probably release the static part as a separate project.</p>
<p>Pinging <a class="mention" href="/u/josevalim" rel="nofollow">@josevalim</a> because he shown interest in these optimizations. By the way, I’ve solved allnproblems related the optimization of macro expansion. Everything “just works” now in an intuitive way.</p>
<p>A macro that can be optimized is just something which expands into a <code>Segments.undead_container(segments, meta)</code>.  This is itself a macro that hides the weird structure of the building blocks of my templates, which are nested 2-tuples (for technical reasons).</p>
<p>So it’s now actually very easy to write an HTML helper that optimizes properly: it’s just a macro that expands into the above (possibly using other helpers).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="100363" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/phoenixundeadview-lets-discuss-optimization-possibilities-for-something-like-phoenix-liveview/16533/60">Post #59</a>
	                </div>
	            </div>
              <div id="likers-container-100363" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="100363"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #59"></div>
  </section>
</div>
    <div class="postbit" id="100584" data-post-id="100584">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tmbb" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tmbb
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>(Very boring post asking for naming feedback)</p>
<p>I’ve changed <code>Segment.undead_container(segments, meta)</code> to <code>Segment.container(segments, meta)</code>, because I might change the <code>Undead</code> namespace to something else.</p>
<p>The prefix <code>PhoenixUndeadView</code> is too bulky and it started out as a “parody” of <code>Phoenix.LiveView</code> (I couldn’t have my project under the <code>Phoenix</code> namespace, so I dropped the dot). But this assumes that the <code>UndeadTemplates</code> (the only concrete thing that came out of this) would be used in something like <code>Drab</code> or <code>LiveView</code> to get minimal diffs.</p>
<p>But the Undead templates are probably more generally useful, so maybe they should have their own package. Because <code>PhoenixUndeadView</code> is too bulky, I’m thinking of having everything under a smaller namespace. I’ve thought of the following possibilities:</p>
<p>Related to undead creatures:</p>
<ul>
<li><code>Undead</code> (name says all)</li>
<li><code>Zombie</code>, (package name taken)</li>
<li><code>Ghoul</code>, (package name taken)</li>
<li><code>Ghost</code>, surprisingly free</li>
<li><code>Necromancer</code>, a wizard that controls the undead</li>
<li><code>Vampire</code></li>
<li><code>Vampyre</code> (like the above, but kooler bekause “Y” iz kooler than “I”). Also a mythical creature that flies.</li>
</ul>
<p>Mythical creatures (some of them birds):</p>
<ul>
<li><code>Garuda</code>, a mythical Indian bird, but has been used in a book about Phoenix as an alternative web framework (so it’s as good as taken)</li>
<li><code>Firebird</code>, a mythical bird from Russian folklore, also the name of a database, which might be confusing</li>
<li><code>Harpy</code>, mythical bird-women from greek mythology</li>
<li><code>Bennu</code>, like Phoenix but Egyptian and older</li>
<li><code>Horus</code>, <code>Ra</code>, <code>Thoth</code>, Egyptian gods which are part birds. <code>Anubis</code> is the god that juges the dead, even though it’s not a bird (it’s a dog)</li>
</ul>
<p>I’m partial towards <code>Vampyre</code>/<code>Vampire</code>. The goal would be to mimic the module structure under <code>Phoenix.HTML</code>:</p>
<ul>
<li><code>Phoenix.HTML</code> becomes <code>Vampyre.HTML</code></li>
<li><code>Phoenix.HTML</code> becomes <code>Vampyre.HTML.Tag</code></li>
<li><code>Phoenix.HTML.Engine</code> becomes <code>Vampyre.HTML.Engine</code>, etc.</li>
</ul>
<p>This means it should be easy to swap the imports in your Phoenix project, should you choose to use Vampyre templates. Instead of having:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def view do
  quote do
    # ...
    use Phoenix.HTML
    # ...
  end
end
</code></pre>
<p>you could just write:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def view do
  quote do
    # ...
    use Vampyre.HTML
    # ...
  end
end
</code></pre>
<p>And configure your <code>eex</code> engine like this (<a href="https://hexdocs.pm/phoenix/Phoenix.Template.html#module-custom-template-engines" rel="noopener nofollow ugc">according to the docs, haven’t tested it yet</a>):</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">config :phoenix, :template_engines,
  eex: Vampyre.Template.EExEngine
</code></pre>
<p>If I ever get around to writing a <code>PhoenixUndeadView</code>, I could use <code>Vampyre</code> templates, which would be fitting, because they are undead and all that.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="100584" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/phoenixundeadview-lets-discuss-optimization-possibilities-for-something-like-phoenix-liveview/16533/61">Post #60</a>
	                </div>
	            </div>
              <div id="likers-container-100584" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="100584"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #60"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/16533/load_more?page=7">Load more posts (81 remaining)</a>
</div></template></turbo-stream>