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

Add Goox Component System #1

Open
aleksei0807 opened this issue Dec 6, 2016 · 1 comment
Open

Add Goox Component System #1

aleksei0807 opened this issue Dec 6, 2016 · 1 comment

Comments

@aleksei0807
Copy link
Contributor

package someComponent

type Comp struct {
    GooxComponent
}

func (c *Comp) Render() GooxComponent {
    return (
        <div class="some-component">
            {c.Childs}
        </div>
    )
}
package template

import "someComponent"

func Render() GooxComponent {
    var s = <span>span from var</span>
    return (
    <someComponent.Comp>
        <div class="abc" style={ GooxStyle{ Padding: 10 } }>
            <p>Goox demo</p>
            {s}
        </div>
    </someComponent.Comp>
    )
}
package main

import (
    "template"
    "fmt"
)

func main() {
    fmt.Println(template.Render())
}

should print in console:

<div class="some-component">
    <div class="abc" style="padding: 10px">
        <p>Goox demo</p>
        <span>span from var</span>
    </div>
</div>

also should be printable as a struct with fmt.Printf("%#+v", gooxcomp) and be compatible to work with struct syntax like gooxcomp.Style.Padding

@kirillDanshin
Copy link
Collaborator

@aleksei0807 +1

@aleksei0807 aleksei0807 changed the title add jsx-like syntax and types Add Goox Component System Feb 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants