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

Can I use "content" in etlua? #756

Closed
impul-so opened this issue Oct 5, 2022 · 1 comment
Closed

Can I use "content" in etlua? #756

impul-so opened this issue Oct 5, 2022 · 1 comment

Comments

@impul-so
Copy link

impul-so commented Oct 5, 2022

Hi Leafo,

Is content a reserved method for future? Can I use in my .etlua?

--app.lua
app:enable("etlua")
app:get("/test", function(self)
   if self.params.show then
      self.content = "Hello World"
   end
  return {
      layout = false,
      render = "test"
  }
end)
--views/test.etlua
<%=content or "Hi"%>

I found this:

content: => -- implement me

@leafo
Copy link
Owner

leafo commented Nov 7, 2022

the content method you linked is specific to class based widgets, the extending class is responsible for implementing the content method to have it render to anything. Class based widgets are completely separate from the etlua template renderer

Within an etlua template you can access variables you've assigned to the request object by using self, so in your case you can reference self.content in the template

@leafo leafo closed this as completed Dec 14, 2022
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

No branches or pull requests

2 participants