Vapor Swift - Compare Two Lines

I would like to compare a variable with a string in my worksheet template.

I get the variable through the controller in my template:

<!-- NAVBAR -->
<!-- #(path) = /database -->
<nav class="navbar navbar-default">
    <div class="container-fluid">
        <ul class="nav navbar-nav">
            #if(path == "/database") {
                <h1>Hello, there!</h1>
            }
            <li><a href="#">Filldatabase</a></li>
        </ul>
        <ul class="nav navbar-nav navbar-right">
            <li><a href="#">Contact</a></li>
        </ul>
    </div>
</nav>
<!-- END NAVBAR -->

I want that when I'm on the page /database, I get h1 that says "Hello, there!". How should I do it? I think I need to use #if(), but I cannot find the correct syntax.

+4
source share
1 answer

What you are looking for is a tag #equal(). You pass two parameters, and if they are the same, then include HTML in curly braces:

#equal("hello", "hello") {
    <!-- This is shown -->
    <p>Equal</p>
}
#equal("hello", "world") {
     <!-- This is not shown -->
     <p>Not Equal</p>
}

So you want to use this:

#equal(path, "/database") {
    <h1>Hello, there!</h1>
}
+3
source

Source: https://habr.com/ru/post/1682649/


All Articles