-
-
Notifications
You must be signed in to change notification settings - Fork 579
integrated with plush's own partial (and added testcases) #1411
Conversation
Travis and AppVeyor failed on these test cases. To solve issue #1406, it should be passed. |
@sio4 this is great! Thinking about what you've dug up, I agree that Plush should have a Does that sound right to you? If so, I would love it if you could own this. :) |
Hi @markbates Anyway, This PR is for testing the For the implementation of partial, as I already wrote as comments on the issue, #1406 (comment) , But since it still not working, we need to fix it and I think the patch for If you agree, I will open another PR for |
No problem. :) I was agreeing 100% with you. 👍
does that help? |
Yes, I think that will help. Anyway, currently, that feature is broken status so we need to fix it first. |
@markbates Something like this? In plush side, add this and register it as "partial" helper: func partialHelper(name string, data map[string]interface{}, help HelperContext) (template.HTML, error) {
for k, v := range data {
help.Context.data[k] = v
}
f := reflect.ValueOf(help.Context.data["partialFeeder"])
args := []reflect.Value{reflect.ValueOf(name)}
res := f.Call(args)
body, err := Render(res[0].Interface().(string), help.Context)
if data["layout"] != nil {
return partialHelper(
data["layout"].(string),
map[string]interface{}{"yield": template.HTML(body)},
help,
)
}
return template.HTML(body), err
} (before call it from and in application side, implement something like this and register as "partialFeeder" helper: func (s templateRenderer) partialFeeder(name string) (string, error) {
d, f := filepath.Split(name)
name = filepath.Join(d, "_"+f)
if filepath.Ext(name) == "" {
name += ".html"
}
source, err := s.TemplatesBox.MustBytes(name)
if err != nil {
return "", err
}
return string(source), nil
} I didn't see in details but it passed most test cases of buffalo's |
Some fix for JS: ct := help.Context.data["contentType"]
if ct != nil && strings.Contains(ct.(string), "javascript") && strings.Contains(name, "html") {
body = template.JSEscapeString(string(body))
} The codes above just before returning This approach breaks current calling structure but I think we cannot avoid changes on both plush and buffalo if we move |
Hi @markbates, how do you think about my approach? If you agree, I will start to code it. Please remember, the |
Hi @sio4 sorry I haven't responded earlier, but I've been busy, and I don't think this is as wide spread and urgent as you think, as no one else is complaining off it, however, I agree it needs fixing, and I would like to get it into a A few questions:
If this isn't a breaking change, then please, start ASAP. :) |
Hi @markbates, Let's start! |
I pushed two PRs on buffalo and plush. PR on plush is just adding a new helper and this PR uses that change. (so currently related test cases are failed on CIs, but I tested it locally.) As @markbates asked, these changes do not affect other applications using plush but buffalo should be updated with this PR. I also removed codes using reflection and changed with as your recommendation. Please check this. |
@sio4 can you rebase this against |
Sure, I will do that by today.
Since now I am on the road, just after an hour or two.
…--
...and in the end, the love you take is equal to the love make
2018년 10월 31일 (수) 22:33, Mark Bates <notifications@github.com>님이 작성:
@sio4 <https://github.com/sio4> can you rebase this against master? I
want to cut a v0.13.x release with this, but development is not ready to
be released. Thanks.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1411 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEPHsrmsuJzx-WqhqweVjRZskZKpb9eks5uqaaegaJpZM4X7hFm>
.
|
no rush. :) i know its the end of day for you.
…-----------
Mark Bates
On Oct 31, 2018, 9:51 AM -0400, Yonghwan SO ***@***.***>, wrote:
Sure, I will do that by today.
Since now I am on the road, just after an hour or two.
--
...and in the end, the love you take is equal to the love make
2018년 10월 31일 (수) 22:33, Mark Bates ***@***.***>님이 작성:
> @sio4 <https://github.com/sio4> can you rebase this against master? I
> want to cut a v0.13.x release with this, but development is not ready to
> be released. Thanks.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#1411 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAEPHsrmsuJzx-WqhqweVjRZskZKpb9eks5uqaaegaJpZM4X7hFm>
> .
>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
d5e1dd0
to
f23f730
Compare
Hi @markbates, I pushed new commits with the same changes against |
I briefly closed/re-opened the PR to see if that will trigger CI |
Thanks! |
Hi, @markbates and all,
Added a test case for issue #1406. I think the solution to this issue should be in
plush
and I tested with patch below: