gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75.36k stars 7.49k forks source link

Document Amber templates #1064

Closed bep closed 9 years ago

scottcwilson commented 9 years ago

I'm not seeing these in https://github.com/spf13/hugoThemes/ but if you give me a pointer, I'd be happy to do this.

bep commented 9 years ago

I guess I need the documentation as much as the common man. It was added by someone, do not remember who. I guess a little code digging would be needed.

But something in the line of the doc for the Ace templates:

http://gohugo.io/templates/ace/

scottcwilson commented 9 years ago

I'm not positive this works. I can create (for example), themes/MY_THEME/layouts/_default/single.ace (after deleting single.html) with "hello world" and it works like a charm, but when I create single.amber with the same content and run hugo, my single pages are all empty.

bep commented 9 years ago

I haven't looked into Amber syntax, but I do not expect it to be the same as Ace. A wrong template may yield an empty rendred page (not ideal, but I guess it could).

If you find a Amber template out there that you know is valid and test with that. If it's not working, then that is valueable info, too.

scottcwilson commented 9 years ago

I searched Github for Amber templates for Hugo and didn't find any. You are correct, the syntax is quite different but I would expect to be able to create a page that just says "Hello World" with no markup and have that work.

We may need to wait for an Amber expert to create a template. If I had a working template, I am sure I could reverse engineer it and write the documentation.

bep commented 9 years ago

Here are some:

https://github.com/eknkc/amber

scottcwilson commented 9 years ago

That's the Amber project. I mean a working Hugo template that was created from Amber.

bep commented 9 years ago

There was a flaw in the Amber logic, see e3ea4b48a274770d8a45fe7c1dbbce2340ec4e2d

I have tested OK with this simple template:

https://github.com/eknkc/amber/blob/master/samples/basic.amber

I notice that we have some work to do to get inheritance support up and running. But that is out of scope for this task.

scottcwilson commented 9 years ago

Thank you so much! I also added a comment to that PR.
I will start working on the docs again.

tatsushid commented 9 years ago

As I wrote http://discuss.gohugo.io/t/amber-templates-not-working-documentation/129, Amber template doesn't allow to call FuncMap function yet. Sorry, I forgot sending PR to Amber. I'll do it later.

scottcwilson commented 9 years ago

Thank you @tatsushid.

tatsushid commented 9 years ago

I sent PR to Amber https://github.com/eknkc/amber/pull/36 to support FuncMap functions and struct's method calls

scottcwilson commented 9 years ago

Quick update: thanks to @bep's fix, the following will work inside, for example, layouts/_default/single.amber:

import ../partials/test.html

import ../partials/test_a.amber

however, this does not work:

{{ partial "test" . }}

It just renders as if it was regular text. So does normal Go syntax not work with Amber? Is this expected?

tatsushid commented 9 years ago

Amber has its own syntax and doesn't allow to use original Go template syntax in it. So, please read https://github.com/eknkc/amber and try. I recommend writing a very simple theme in normal Go template syntax first and converting it into Amber one by one. That's the way I did when I added Ace template syntax to Hugo

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.