Grow a Treemote!

Python 3.5, 76 75 73 bytes:

(Thanks to Blue for a tip which saved 2 bytes!)

def i(n):q=len(n);z=('|'+' '*(2+q)+'|\n')*-(-q//2);print(z+'| '+n+' |\n'+z)

Try It Online! (Ideone)

Also, here is a noncompeting Python 2.7.5 version since it is much longer at 87 bytes.

def i(n):q=len(n.decode('utf-8'));z=('|'+' '*(2+q)+'|\n')*-(-q/2);print z+'| '+n+' |\n'+z

This is because Python 2's default encoding is ascii, and therefore, characters such as outside the 128 unicode point range count as more than 1 byte (list('ಠ') yields ['\xe0', '\xb2', '\xa0']). The only workaround I could think of for this was to first decode the input using utf-8, and then move on with this utf-8 decoded string.

Try This Python 2 Version Online! (Ideone)


05AB1E, 27 25 bytes

Code:

g©Ìð×"|ÿ|
"®;îש„| ¹s¶®J

Explanation:

g                  # Push the length of the input string.
 ©                 # Copy that to the register.
  Ì                # Increment by 2.
   ð×              # Multiply by spaces.
     "|ÿ|\n"       # ÿ is used for interpolation and push the string "|spaces|\n".
                   #
 ®                 # Retrieve the value from the register.
  ;î               # Divide by 2 and round up.
    ×              # Multiply that by "|spaces|".
     ©             # Copy this into the register.
      „|           # Push the string "| ".
         Â         # Bifurcate, pushing the string and the string reversed.
          ¹s       # Push input and swap.
            ¶      # Push a newline character.
             ®J    # Retrieve the value from the register and join everything in the stack.
                   # Implicitly output this.

Uses CP-1252 encoding. Try it online!.


Dyalog APL, 37 34 33 bytes

{↑'|'{⍺⍵⍺}¨b,(⊂⍵),b←' '/⍨⌈0.5×≢⍵}

Chrome users: See footnote*

Test cases

      f←{↑'|'{⍺⍵⍺}¨b,(⊂⍵),b←' '/⍨⌈0.5×≢⍵}
      
      f,'☺' ⍝ the , is necessary to create a 1 char string instead of a character scalar
|   |
| ☺ |
|   |
      f':D'
|    |
| :D |
|    |
      f'^_^'
|     |
|     |
| ^_^ |
|     |
|     |

*Chrome misdisplays the two characters ≢⍵ (U+2262,U+2375) as ≢⍵ (U+2261,U+0338,U+2375) instead of as ̸≡⍵ (U+0338,U+2262,U+2375), so here is a display version for Chrome: {↑'|'{⍺⍵⍺}¨b,(⊂⍵),b←' '/⍨⌈0.5×̸̸≡⍵}