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

Recursive partials:: Uncaught RangeError: Maximum call stack size exceeded #14

Open
JohnRSim opened this issue Dec 20, 2013 · 5 comments

Comments

@JohnRSim
Copy link

Getting an error when trying to attempt recursive partials is this a bug?

hogan.js:321
Uncaught RangeError: Maximum call stack size exceeded

It generates first level "User Folder" and then errors -

//Structure 
var folderStructure = [
    {
        childFolders: [{
            folderName: 'User Folder',
            folderOpen: true,
            CS_query:   '',
            childFolders: [
                {
                    folderName: 'test1',
                    CS_query:   ''
                },
                {
                    folderName: 'test2',
                    CS_query:   ''
                },
                {
                    folderName: 'test3',
                    CS_query:   ''
                }
            ]
        }]
    }
];

//gen tpl
documentsTpl({
    data:   folderStructure,
},{
    folderList: folderList.template
});
//documentsTpl.mustache
<ul class="listView documents" style="display:block">
    {{#folderStructure}}
        {{>folderList}}
    {{/folderStructure}}
</ul>

//folderList.mustache
{{#childFolders}}
    <li>
        <div class="folderList">
            <ul class="listView documents">
                {{>folderList}}
            </ul>
        </div>
    </li>
{{/childFolders}}

Thanks

@millermedeiros
Copy link
Owner

I don't know if hogan supports recursive partials (probably not). So this issue should not be related to the plugin.

@JohnRSim
Copy link
Author

There is a test in hogan.js git for recursive partials.. - just tested in on my machine and it works -

https://github.com/twitter/hogan.js/blob/936e00f1e60c8b7a0100c64c6ea031e290c75a32/test/index.js
line 1163 Context inheritance in recursive partials

@JohnRSim
Copy link
Author

I copied in the recursive test and tried it but failed with the same error -
Uncaught RangeError: Maximum call stack size exceeded

//data
var list = {
    list: [
        { foo: 1 },
        { foo: 2 },
        { foo: 3, sub: { list: [{ foo: 4, sub:false }, { foo: 5, list:[], sub:true }] } }
    ]
};

//gen tpl
dTpl = documentsTpl(
    list
,{
    folderList: folderList.template
});
//documentsTpl.mustache
{{#list}}
    {{foo}} > 
    {{#sub}}
        {{> folderList}}
    {{/sub}}
{{/list}}

//folderList.mustache
Start > {{> folderList}}

Should output
Start > 1 > 2 > 3 > 4 > 5 >

@JohnRSim
Copy link
Author

millermedeiros Any thoughts? - recursive partials work direct with hoganjs without the requirejs plugin..

@millermedeiros
Copy link
Owner

maybe it doesn't work because the recursive partial uses some property that we are not included on the render method or because we bind the context... I probably won't have time to investigate this anytime soon. Pull requests are highly appreciated.

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