Comments (4)
apologies if I'm just misunderstanding what the url extension should do.
possibly you could drop this in favor of the helper extension, which allows url.site (I think?)
from kohana-twig.
Route::get() works just fine for me. How are you using the tag?
{% url {route_name}, {parameters} %}
For example to load the edit action on the posts controller you would use the following:
{% url "default", ["controller":"posts", "action":"edit", "id":"my-post"] %}
Hope that helps?
Cheers,
Aron
from kohana-twig.
I see, thanks.
Should that tag be called "route" then? Since it relates directly to the Route helper, that makes more sense to me anyway.
I was using this tag, trying to link to a static asset e.g.
{% url '/img/foo.png' %}
or, in general, I find it easier, simpler, clearer to just use URL format (especially if the template coders are not backend devs, and shouldn't need to know controller, action, etc)
e.g.
{% url 'posts/edit/1' %}
from kohana-twig.
Ideally you should be able to rename the tags by simply creating your own Twig_URL_TokenParser
and redefining the getTag()
method to return 'route'. However unfortunately the Twig module doesn't conform to the Kohana design principals with it's tag implementation.
For your static assets you could either create a tag module for the URL class or a simpler solutions would be to define a "base_url" variable in your controller set to URL::base(TRUE, TRUE)
and use this in your views.
<img src="{{ base_url }}/img/foo.png" />
I'd argue that you should always use the controllers and actions in your views even if it does make them appear more complex as it decouples the site URLs from the templates. This means that in the future should you decide to modify your applications routes, for example adding a prefix or swapping the parameters around, all your templates will still generate correct links and not require any modification.
Cheers,
Aron
from kohana-twig.
Related Issues (11)
- Use Kohana::find_file ? HOT 3
- Twig_Loader_String HOT 2
- Helper Parser is broken HOT 1
- Asset extension missing Asset class? HOT 2
- Extensions could have a docs HOT 1
- install docs would be nice HOT 2
- Twig module does not follow Kohana's HMVC design
- Trans_TokenParser has wrong classname HOT 1
- Stacktrace is always shown.
- Use this to make twig faster with kohana HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kohana-twig.