Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Http preprocessor improvement #364

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

chowette
Copy link
Contributor

  • Change escaping of raw text to use long string
    lua has [[ ]] for raw string embedding
    This allow us to not track string quotes and output bigger chunk.
    The downside is that we are more likely to hit the buffer size limit of 2k, and miss a lot of preallocated buffer use. So we need to track the length of the line and break.
    This change also preserve blank line in raw text.
  • change extension of http server file to .luasp for lua server pages
    Avoid confusion with real lua file, and allow editor highlighting based on extension
    Note that preprocessed file end up with extension .luaspp
  • add support for tag <?lua= expression ?>

In any case, your lua code should not include the ending tag
so <?lua print('?>') ?> is malformed and should be rewritten by hand to <?lua print('?'..'>') ?> for exemple.

lua has [[ ]] for raw string embedding
This allow us to not track string quotes and output bigger chunk.
The downside is that we are more likely to hit the buffer size limit of 2k, and miss a lot of preallocated buffer use. So we need to track the length of the line and break.
This change also preserve blank line in raw text.
Avoid confusion with real lua file, and allow editor highlighting based on extension
Note that preprocessed file end up with extension `.luaspp`
Copy link
Collaborator

@the0ne the0ne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

System Lua scripts should not reside in the webserver directory.
Webserver Lua scripts should not reside outside of the webserver directory.
I don't see a benefit in adding another file extension.

@chowette
Copy link
Contributor Author

I agree with you about file location and separation. However, Webserver script pages are not lua scripts, they are html files with some part containing lua fragment of script. It is not uncommon to have lua statement split and interleaved with 'raw text'.
It this case, most editor with syntactic coloration cannot display the file as lua.

Compare

<html>
<body>
<table>
<?lua for i=1,10 do ?>
<tr><td> <?lua print(i)  ?></td></tr>
<?lua  end ?>
</table>
</body>
</html>

to

<html>
<body>
<table>
<?lua for i=1,10 do ?>
<tr><td> <?lua print(i)  ?></td></tr>
<?lua  end ?>
</table>
</body>
</html>

If both files have, the same extension, is it way harder to instruct your editor how to colorise the file.

Finally, there is no sense in doing dofile('index.lua') but you cannot do dofile('index.luasp')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants