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

template function for css and js? #4

Open
niklasgrewe opened this issue Sep 10, 2023 · 0 comments
Open

template function for css and js? #4

niklasgrewe opened this issue Sep 10, 2023 · 0 comments

Comments

@niklasgrewe
Copy link

Hi @kataras thank you very much for creating the iris framework and blocks. I am new to go but i miss something to get started. I have basic view folder with an index.html like this:

<h1>Index Body</h1>
<h3>Message: {{.Message}}</h3>

<style>
  h1 {
    color: red;
  }

  h3 {
    color: green;
  }
</style>

<script>
  alert('Hello World');
</script>

inside my layouts/main.html file i define the templates css and js like this:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>{{.Title}}</title>
  {{ template "css" . }}
  {{ template "js" . }}
</head>
<body>
  {{ template "content" . }}
  {{ partial "partials/footer" . }}
</body>
</html>

You can probably already guess what I would like to achieve. The styles and the js code from the index.html should be inserted into the main.html automatically, just like it happens with the content template function.

Is that possible? How can i achieve this? Could blocks support this as well?

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

1 participant