Getting current URL in templates.
-
Thanks for that, so in the template how can I use the IF functions, I'm not too sure on this stuff..
<!-- IF location.pathname IS "/followers" --> ?
or = or something else? -
@William-Haskell I won't lie to you buddy. I haven't got a clue. I'll ping @psychobunny because it's his template engine.
-
Thanks
-
Try
<-- IF followers.length --> <-- IF following.length -->
-
If I use that, it displays only on followers/following page.
!followers.length doesn't seem to work and edit.length doesn't work either so I'm not sure how to do this :s
-
You can also use
ELSE
. So, if I'm not mistaken, something like<!-- IF followers.length --> <!-- ELSE --> Code here <!-- ENDIF followers.length -->
May produce better results.
-
Yep, that works, but there's also another pages using the menu at the top that I've just noticed.
Is there a way to check if the page is just settings or edit?
These seem to be the only ones that need the button.
-
We can possibly add the name of the current template into the api return. So that you can do stuff like
<!-- IF account/edit--> only shows up on edit page <!-- ENDIF account/edit -->
in
partials/account_menu.tpl
for example.account/edit
will be true when you are on the urluser/:username/edit
and false everywhere else.So to solve your problem you would have to do
<!-- IF account/edit--> <!-- IMPORT partials/mySpecialButton.tpl --> <!-- ENDIF account/edit --> <!-- IF account/settings --> <!-- IMPORT partials/mySpecialButton.tpl --> <!-- ENDIF account/settings -->
So you can include a special template if the page is edit or settings.
@psychobunny thoughts?
-
yeah that makes sense to me. tbh maybe we should add the name of the template for all returns as a global var? so that there's no confusion for any custom routed api call -> templates such as the above routes
-
sounds gud