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

Selectable templates by having a directory each? #20

Closed
o-jasper opened this issue Mar 9, 2014 · 6 comments
Closed

Selectable templates by having a directory each? #20

o-jasper opened this issue Mar 9, 2014 · 6 comments

Comments

@o-jasper
Copy link

o-jasper commented Mar 9, 2014

I tried to make each directory a set of templates, but so far it is creating weird bugs.

The bugs seem to care between other_function(functional_function()); and var a=functional_function(); other_function(a);, the former giving an error. Programming languages should in principle not care about that... The latter gives memory leaks issues..

Could do the same as with assets/...

Just like my other issue, probably low priority.

@k1n0k0
Copy link
Collaborator

k1n0k0 commented Mar 10, 2014

Ah there's some magic going on here. fs.readFileSync needs a string literal for the filepath, because the files' contents are actually inlined, replacing the fs.readFileSync call.

This magic is provided by brfs. Thats the only magic at work, i'm pretty sure. sorry for the confusion!

@o-jasper
Copy link
Author

Right... It is essentially macro-ifies the function so browsers can handle it.. Glad i didnt push too hard, it would have taken me too much time to find out myself.. Thanks for the reponse :) I should have looked at documentation about it.

Strangely i do see you can use a parameter __dirname, and add it, not found yet how to use those though. If you could you'd only need to change one parameter; './templates/default/blala' you'd do __templates + 'blabla'.

@k1n0k0
Copy link
Collaborator

k1n0k0 commented Mar 11, 2014

__dirname is provided by node, so I think it is looking for that variable explicitly.

Here is the brfs is regarding dynamic require statements

@k1n0k0
Copy link
Collaborator

k1n0k0 commented Mar 11, 2014

I'm going to close this issue, but I'm happy to continue the discussion.

@k1n0k0 k1n0k0 closed this as completed Mar 11, 2014
@o-jasper
Copy link
Author

Browserify has this argument.

--insert-global-vars, --igv
Comma-separated list of global variables to detect and define.
Default: __filename,__dirname,process,Buffer,global

Beefy should be able to pass that along. So in the "start" entry of package.json, i put beefy app.js:bundle.js --open --live -- --insert-global-vars __filename,__dirname,process,Buffer,global,__templateFiles -t brfs It doesnt work if i put the definition var __templateFiles='./templates/default/' in lib/view.js, but it crashes if i put it in;

 /home/jasper/oproj/coin/ethereum/ethereum-simulator/node_modules/browserify/node_modules/insert-module-globals/index.js:82
            var value = vars[name](file, basedir);
                                  ^
 TypeError: Property '__templateFiles' of object #<Object> is not a function
at /home/jasper/oproj/coin/ethereum/ethereum-simulator/node_modules/browserify/node_modules/insert-module-globals/index.js:82:39

Edit: totally okay with it being closed. Otherwise the open issue list grows unmanagably..

@k1n0k0
Copy link
Collaborator

k1n0k0 commented Mar 15, 2014

At some point I will move to a more dynamic build system and then this part should be easier to deal with.

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