menu

Imba

The language for building next-gen web applications

Channels
Team

If-statement based on routing w/ imba-router

January 26, 2019 at 4:46pm

If-statement based on routing w/ imba-router

January 26, 2019 at 4:46pm (Edited 10 months ago)
Does anyone know if it’s possible to do an ‘if statement' based on routing with Imba-router?
can your pro-router do it ?
tag App
def render
<self>
<h1 route=“/“> “You are home”
<h1 route=“/other“> “You are on another page"
# If home, show ‘other' button
if route == ‘/‘
<button route-to=“/other”>
# else show home button
else
<button route-to=“/">
Imba.mount <App>
Fedor Leschinsky 23:41
if router.path.includes(‘other’)
Fedor Leschinsky 23:44
router.path is just a string containig route. You can analize it as you wish
Eric Tirado 23:44
you probably don’t need imba-router to use router.path right?
Fedor Leschinsky 23:44
Preventing further questions if you will need to change route from code use router.go
You need imba-router. It is imba router functiinality
When you use imba router you have “router” object in your tags

January 26, 2019 at 6:09pm
Marek Piasecki 00:53 In pro router you do it this way if R.param('name-of-the-parameter') or if R:view == 'expected-view'
Edited
  • reply
  • like