Closed zcsteele closed 12 years ago
I'm not sure a new method is needed for this. You should be able to specify layout = false
in the data you pass to render. We use this for sending fragments loaded via XHR.
I'm not entirely sure I understand what you mean... I am able to disable the layout file by setting the layout property to false, but using that approach each handler method needs to save a copy of the existing layout and restore it after rendering/sending the XML fragment so future non-XHR requests are handled correctly.
Are you referring to some other mechanism to disable the layout file for a single call to render()? I don't see anything in the code that looks like it work, and nothing I try generates the appropriate output.
BTW, thanks for looking over my code.
You should be able to do it on a per-render basis, but it looks like it might only work properly for Soy templates (the codes a bit of a mess).
this.render(res, 'templateFile', {
layout: false,
otherProperty: 'booya'
})
Yep, it doesn't work for hogan templates. I think that would be the good fix if you are interested in making a patch. Or I can take a look.
Checkout this PR: https://github.com/Obvious/matador/issues/98
Does that solve your problems?
Yep! Thank does it. I like that version better anyhow; it has less duplicated code.
Cool. Will merge and publish to npm shortly. On Aug 20, 2012 3:15 PM, "zcsteele" notifications@github.com wrote:
Yep! Thank does it. I like that version better anyhow; it has less duplicated code.
— Reply to this email directly or view it on GitHubhttps://github.com/Obvious/matador/pull/97#issuecomment-7885452.
Ok, all done.
The existing render() method works fine for standard page requests, but generating a page via views/layout.html is not useful for AJAX requests. To allow my server code to use Mustache within XML reponses, I made an alternate method, renderXML(). This method is nearly identical to the existing method render(), but it does not specify a layout file. The resulting HTML structure contains only the HTML snippet from the file named in the method call.