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

Mixins doesn't work #30

Open
sgirones opened this issue Oct 17, 2014 · 1 comment
Open

Mixins doesn't work #30

sgirones opened this issue Oct 17, 2014 · 1 comment

Comments

@sgirones
Copy link

Pasted the code and error

main.go

package main

import (
    "log"

    "github.com/eknkc/amber"
)

func main() {
    res, err := amber.CompileDir("./views", amber.DefaultDirOptions, amber.DefaultOptions)
    if err != nil {
        log.Print(err)
    }
    log.Print(res)
}

views/a.amber

mixin a
  foo

views/b.amber

+a

err:

2014/10/17 17:22:56 Amber Error in <views/b.amber>: runtime error: invalid memory address or nil pointer dereference - Line: 1, Column: 1, Length: 2

Any idea?

@lepoetemaudit
Copy link

Hi, this is a bit old but I figured this out in case anyone else is interested.

First of all, you'll need to import "a" in b, so:

views/a.amber

mixin a
  foo

views/b.amber

import a
  +a

However, one gotcha I found is that if you are extending another template and are overriding blocks, for your mixin to be visible to the blog you have to import INSIDE of the block, e.g.

extends layout
    block content
      import my_mixins
        +my_awesome_mixin("hello!")

If you try and import outside of the block, it isn't visible. I'm not sure if this is by design or not.

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