You are viewing a plain text version of this content. The canonical link for it is here.
Posted to site-dev@apache.org by sebb <se...@gmail.com> on 2015/09/04 15:49:49 UTC

Re: svn commit: r1701061 - /infrastructure/site/trunk/content/dyn/closer.lua

On 3 September 2015 at 17:23,  <hu...@apache.org> wrote:
> Author: humbedooh
> Date: Thu Sep  3 16:23:14 2015
> New Revision: 1701061
>
> URL: http://svn.apache.org/r1701061
> Log:
> new parser works, put in production \o/
>
> Modified:
>     infrastructure/site/trunk/content/dyn/closer.lua
>
> Modified: infrastructure/site/trunk/content/dyn/closer.lua
> URL: http://svn.apache.org/viewvc/infrastructure/site/trunk/content/dyn/closer.lua?rev=1701061&r1=1701060&r2=1701061&view=diff
> ==============================================================================
> --- infrastructure/site/trunk/content/dyn/closer.lua (original)
> +++ infrastructure/site/trunk/content/dyn/closer.lua Thu Sep  3 16:23:14 2015
> @@ -74,44 +74,11 @@ function recurse(url, defs, tdata, r, ez
>          end
>      )
>
> +    -- Parse EZT
> +    local structure = ezt:import("[ezt]"..tdata.."[end]")

Why is the data wrapped in [ezt]/[end] ?
Is that really needed?

It messes up reporting of mismatched [end] markers.
The line number is shown for the wrapper [end] rather than the one in
the template

> -    if defs.debug then
> -        local structure = ezt:import("[ezt]"..tdata.."[end]")
> -        return ezt:construct(structure, ezt_defs)
> -    else
> -        tdata = tdata:gsub("%[if%-any%s+([a-z0-9_]+)%](.-)%[end%]",
> -            function(tag, middle)
> -                --print("Got if-any", tag, " recursing it...", #middle)
> -                if url[tag] or mymap[tag] then
> -
> -                    tdata = recurse(url, defs, middle, r)
> -                    return tdata
> -                else
> -                    return ""
> -                end
> -            end
> -        )
> -        tdata = tdata:gsub("%[for%s+([a-z0-9_]+)%](.-)%[end%]",
> -            function(tag, middle)
> -                if mymap and mymap[tag] then
> -                --   print("Got for:", tag, "recursing")
> -                    local m = ""
> -                 --   print(middle)
> -                    for _, val in pairs(mymap[tag] or {}) do
> -                        defs[tag] = val
> -                   --     print("def", tag, val)
> -                        m = m .. recurse(url, defs, middle, r)
> -
> -                    end
> -                    return m
> -                else
> -                    return ""
> -                end
> -            end
> -        )
> -    end
> -    tdata = tdata:gsub("%[([a-z0-9_]+)%]", function(a) return defs[a] or "[" .. a .. "]" end)
> -    return tdata
> +    -- Render output
> +    return ezt:construct(structure, ezt_defs)
>  end
>
>  function handle(r)
>
>

Re: svn commit: r1701061 - /infrastructure/site/trunk/content/dyn/closer.lua

Posted by sebb <se...@gmail.com>.
On 4 September 2015 at 14:52, Daniel Gruno <hu...@apache.org> wrote:
> On 09/04/2015 03:49 PM, sebb wrote:
>
>>>
>>> +    -- Parse EZT
>>> +    local structure = ezt:import("[ezt]"..tdata.."[end]")
>>
>> Why is the data wrapped in [ezt]/[end] ?
>> Is that really needed?
>>
>> It messes up reporting of mismatched [end] markers.
>> The line number is shown for the wrapper [end] rather than the one in
>> the template
>>
>
> [ezt] .. template .. [end] is needed because it constructs a root tree.
> much like <xml>stuff here</xml> or <html>....</html>.

But <xml>/</xml> need to be in the source file itself.
That is not the case for EZT.

> It is because of how the original parser is designed.

In which case the wrapper should be added in the EZT parser, not by the caller.
And then the check for empty stack could allow for the extra stack level.

But in any case the parser seems to work fine without the wrapper.

> With regards,
> Daniel.
>

Re: svn commit: r1701061 - /infrastructure/site/trunk/content/dyn/closer.lua

Posted by Daniel Gruno <hu...@apache.org>.
On 09/04/2015 03:49 PM, sebb wrote:

>>
>> +    -- Parse EZT
>> +    local structure = ezt:import("[ezt]"..tdata.."[end]")
> 
> Why is the data wrapped in [ezt]/[end] ?
> Is that really needed?
> 
> It messes up reporting of mismatched [end] markers.
> The line number is shown for the wrapper [end] rather than the one in
> the template
> 

[ezt] .. template .. [end] is needed because it constructs a root tree.
much like <xml>stuff here</xml> or <html>....</html>. It is because of
how the original parser is designed.

With regards,
Daniel.