Yes, we can support more markers. The default behaviour though should be to raise (and not be equiavlent to "=").
PR please? *José Valim* www.plataformatec.com.br Skype: jv.ptec Founder and Director of R&D On Sat, Jul 1, 2017 at 12:29 PM, Grych <[email protected]> wrote: > Hi all, > While building my own EEx Engine I encountered an issue, which might be > easily resolved, if EEx.Engine allow to use custom markers. > As it stands in the documentation of EEx.Engine behaviour: > > The allowed markers so far are: "" and "=". > > The EExEngine API is prepared for having custom markers, as handle_expr/3 > receives the marker, but currently it receives only "=" or "". Trying to > put own marker treats it as a part of the expression. > > My proposition is to create a list of additional markers to use by a > developer who writes own EEx Engine. For a begin, it could be: > > - "|" > - "/" > > *(none of those markers should confuse the "" marker, as they should not > appear at the beginning of any Elixr expression)* > > By default, those markers may behave as "=". But when you create your own > EEx Engine, you would be able to override handle_expr/3 for those markers. > > ----------- > Rough example: > > defmodule ExtendedEngine do > use EEx.Engine > > def handle_expr(buffer, "/", expr) do > super(buffer, "=", modified_expression(expr)) > end > > def handle_expr(buffer, mark, expr) do > super(buffer, mark, expr) > end > end > > Current behaviour: > > iex> EEx.eval_string "foo <%/ bar %>", [bar: "baz"], engine: ExtendedEngine > ** (SyntaxError) nofile:1: syntax error before: '/' > lib/eex/compiler.ex:36: EEx.Compiler.generate_buffer/4 > lib/eex.ex:196: EEx.eval_string/3 > (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6 > (iex) lib/iex/evaluator.ex:182: IEx.Evaluator.handle_eval/6 > (iex) lib/iex/evaluator.ex:175: IEx.Evaluator.do_eval/4 > > Expected behaviour: > > iex> EEx.eval_string "foo <%/ bar %>", [bar: "baz"], engine: ExtendedEngine > "foo BAZ" > > > -- > You received this message because you are subscribed to the Google Groups > "elixir-lang-core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/elixir-lang-core/41ec2e19-e249-4a16-bcf3- > def6bb1bc7b2%40googlegroups.com > <https://groups.google.com/d/msgid/elixir-lang-core/41ec2e19-e249-4a16-bcf3-def6bb1bc7b2%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4%2Bhweuk%3D8_Quh%2B5j3%2BHZ3JabpRCtBubHquGKNGO1HMNKA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
