Q:

Jade: mimick simple PHP function

I am currently trying to convert a PHP file into a Jade file to decrease server load*, but have run into some issues with converting the main PHP function - the reason for which that the page is not a HTML file in the first place - into Jade.
The function simplifies the listing of "items", and accepts multiple arguments in order to populate the different parts of the HTML code. 
<?php
 function item( $name, $category, $url, $color, $partner=NULL ) {
    # convert åäö -> aao (lower- and uppercase)
    $filename = preg_replace(array('/å/','/ä/','/ö/','/Å/','/Ä/','/Ö/', '/\s+/'), array('a','a','o','A','A','O', '-'), $name);
    $filename = strtolower($filename);
  ?>
  <div class="projekt__item item-<?php echo $filename ?>" style="background-color: <?php echo $color; ?>">
    <div class="item__logo item__logo--<?php echo $filename ?>"></div>

    <div class="item__figcaption">
      <span class="item__figtext">
        <?php echo $category; ?><br>
        <?php if ($partner) : ?>
          <br>
          <span class="item__figtext--sub">
            <strong>Partner: </strong> <?php echo $partner; ?>
          </span>
        <?php endif; ?>
      </span>
    </div>

    <a href="<?php echo $url ?>" rel="nofollow" target="_blank"></a>
  </div> <!-- /item -->
<?php } ?>

There are different components of the PHP code which I find difficult to replicate in Jade. These are:

Give one of the passable a variables a default value (e.g. partner=NULL)
Convert "åäö " into "aao_" for lower and uppercase letters
use the variables passed into the mixin in the code without syntax errors

I have set up a pen containing my so progress so far (which isn't very much - it just throws me a couple of errors which does not help me)
If anyone could assist me with this it would be greatly appreciated.
*I am aware of that there are other means to decrease server load, and that caching should make this redundant. However, it is also a matter of learning jade for future reference, and I would very much like to solve this problem instead of just leaving it behind :)
Update:
Thanks to @laggingreflex the problem has been solved. The final solution is seen below:
mixin item(name, category, url, color, partner)
  - var filename = name.replace(/å/g,'a').replace(/ä/g,'a').replace(/ö/g,'o').replace(/Å/g,'A').replace(/Ä/g,'A').replace(/Ö/g,'O').replace(/\s+/g,'-')
  - filename = filename.toLowerCase()

  div(class='projekt__item item-#{filename}' style="background-color: #{color};")
     div(class='item__logo item__logo--#{filename}')
     div.item__figcaption
       span.item__figtext
         | #{category}
         if (partner)
           br
           span.item__figtext--sub
             strong Partner: #{partner}
     a(href=url rel="nofollow" target="_blank")

A:

There's couple of mistakes in your Jade syntax
When defining a mixin method you can't assign default values to arguments.
item(name, category, url, color, partner=NULL) // error
item(name, category, url, color, partner)

btw if you don't pass an argument it's undefined by default.
At some places you're not actually interpolating the values of the variables, but simply outputting the variable names as plain strings
span.item__figtext
  | category // will output the text "category"
  | #{category} // will output the value stored in the variable category

Semi-colons are not a part of the Jade syntax (* unless you're doing inline JavaScript)
+item( "Intern...", ... ); // error
+item( "Intern...", ... )

Update with couple more suggestions
When you want to assign variable values to an attribute you don't want to put them in quotes
a(href="url" //  will output <a href="url"
a(href=url   //  will output <a href="http://example.com"

When using a variable in a class name, you can't use the dot .class notation, so you want to define it as an attribute
div.item-filename    // will output <div class="item-filename"
div.item-#{filename} // will result in error
div(class="item-#{filename}" // this is what you want

As for PHP's preg_replace, .replace is the JavaScript's equivalent, although it doesn't support arrays so you have to chain them, and you have to specify the /g regex modifier specifically.
Also to inline JavaScript code inside Jade you want to begin it with a hyphen -
- var filename = name.replace(/å/g,'a').replace(/ä/g,'a').…

So this is what your completed Jade should look like
mixin item(name, category, url, color, partner)
  //- convert "åäö B C" -> "aao-b-c" (lower- and uppercase)
  - var filename = name.replace(/å/g,'a').replace(/ä/g,'a').replace(/ö/g,'o').replace(/Å/g,'A').replace(/Ä/g,'A').replace(/Ö/g,'O').replace(/\s+/g,'-')
  - filename = filename.toLowerCase()

  div(class='projekt__item item-#{filename}' style="background-color: #{color};") #{filename}
    div(class='item__logo item__logo--#{filename}')
    div.item__figcaption
      span.item__figtext
        | #{category}
        if (partner)
          br
          span.item__figtext--sub
            strong Partner: #{partner}
    a(href=url rel="nofollow" target="_blank")

+item( "Example Name 1 åäö", "Design & Utveckling", "http://www.example_url.com/", "#45c0ae", "Example Partner" )
+item( "Example Name 2", "Design & Utveckling", "http://www.example_url.com/", "#346b98" )
+item( "Example Name 3", "Design & Utveckling", "http://www.example_url.com/", "#8191b2", "Example Partner" )
+item( "Example Name 4", "Design & Utveckling", "http://www.example_url.com/", "#485230", "Example Partner" )

