-
Notifications
You must be signed in to change notification settings - Fork 30
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
Different index.html
reference in preview and generate
#17
Comments
I think you are mixing different concepts together. Why do you think that location is different for index.html during generation and preview phase? The property 'location' in the map of index.html resource will be the same no matter what phase is, it will be '/index.html' |
It is possible, since I don't understand what is the difference. For injecting resource I use not location but url (I think I just copied it from one of your examples). The url is definitely different. What is the difference between location and url? Also there is still problem with references. What should I write inside By the way, since injecting resources is fairly frequent task (at least it is one of the most important features of Grain that other static site generators do not have), there should be some helper methods to do so. |
http://sysgears.com/grain/docs/latest/#variables-on-a-page http://sysgears.com/grain/docs/latest/#standard-tag-library The standard tags are: |
Not sure what do you mean here? Injecting resources by including them inside html? For that there is a model parameters: ${include 'tags.html', [modelVar: 'Some value']} If you are referring to ResourceMapper, then please could you provide some example helpers and what stops you to use usual Groovy approaches to have them in for example your own separate class ? |
But to be really helpful, to be honest, I need to see what problem are you trying to solve with code examples... Abstract discussion usually is not very helpful |
The problem I try to solve is rather simple: I need different types of resources loaded automatically (by type or by directory) and injected into specific page. Usually static site generators allow for single type of injected resources and does no include custom filtering. Grain allows not only to load custom resources, but also filter them and convert on the fly which is very important. But access to these features is rather obscure. I don't know if it is the "right" way to do things, but I usually include resources via
|
Yes, generally you do injection like this. Finding by URL can be non-optimal strategy in certain cases, you can find resource by it.location == location instead. Just try to println some original resource you receive and see what properties contained in its map. The idea is simple, actually. Resource mapper is the first thing that is called on "raw" resources on the file system, Grain throws all the resources on it and expects the resource list to be rendered in return. Resource mapper is free to delete some resource from the original list, or make several copies of resource in original list or can even create new resources on the fly and add them to the map. No means to work with resource lists are provided and I can't imagine yet how these means can look like. Resource mapper just gets list of maps and should return list of maps, usually transformed somehow, with using all the power of Groovy as it needs. This simple and central idea is somehow hidden in the Grain, I agree. |
I usually just use IDEA debug to see what is inside resources objects instead of printing. Well, I got the idea. I currently maintain three different sites using Grain (one is online, two are in development), so when I find any convenient way to add helpers to resource mapping, I will let you know. |
The problem I encountered second time. During preview phase
index.html
has location/
but after generate it is actuallyindex.html
and/
points to directory root. A problem arises when I want to place a link to a home page or inject resources into index.Is there a universal way to reference a page and find it in resources?
The text was updated successfully, but these errors were encountered: