ASCII Airplane Banner

Given two inputs -- one of them a non-empty printable ASCII string (including space, excluding newline), the other being one of two distinct, consistent values of your choice (1 / 0, l / r, left / right, etc.) -- output an ASCII art airplane banner of the string, pointing either left or right. For consistency, I'll be using left and right throughout this challenge description.

The plane is either |-DI>-/ (left) or \-<ID-| (right). Since the banner is clear, it consists of the input string's characters separated by spaces, either left-to-right (left) or right-to-left (right), and surrounded by a box of the shape

    /--/
---<  <
\--\


or

\--\
>  >---
/--/


Note there must be one space between the beginning/end of the message and the >,< characters.

For example, here is the message HAPPY BIRTHDAY! and the direction left:

           /-------------------------------/
|-DI>-/---< H A P P Y   B I R T H D A Y ! <
\-------------------------------\


Here is the message PPCG and the direction right. Note that the letters appear "backwards" when viewed from this side of the banner:

\---------\
> G C P P >---\-<ID-|
/---------/


Rules

• Leading or trailing newlines or whitespace are all optional, so long as the characters themselves line up correctly.
• Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
• If possible, please include a link to an online testing environment so other people can try out your code!
• Standard loopholes are forbidden.
• This is so all usual golfing rules apply, and the shortest code (in bytes) wins.
• Slightly related. – Dom Hastings Aug 29 '17 at 14:58
• JavaScript, 4 bytes: eval - Input a program that generates a left-facing plane for left, and a program that generates a right-facing plane for right. – darrylyeo Aug 30 '17 at 4:17

JavaScript (ES6), 141 138 bytes

String and direction are input via currying syntax.
'/\n|-DI>-/---< ' for left, '/\n|-DI<-\\---> ' for right.

t=>p=>(r=${s=' '}/${_='-'.repeat(t.length*2+1)}${p}${[...t].join } ${d=p[12]}${s}\${_}\\,d>'<'?[...r].reverse().join:r)  f= t=>p=>(r={s=' '}/{_='-'.repeat(t.length*2+1)}{p}{[...t].join } {d=p[12]} {s}\${_}\\,d>'<'?[...r].reverse().join:r)

console.log(f('HAPPY BIRTHDAY!')('/\n|-DI>-/---< '))
console.log(f('HAPPY BIRTHDAY!')('/\n|-DI<-\\---> '))

• Ha, hard coding a section of the output seems like an exploitation of a loophole, but it seems fine based on the challenge as written. Clever! – Rick Hitchcock Aug 30 '17 at 9:14
• @RickHitchcock The ultimate loophole is eval... just provide left and right function sources as your two values of your choice. (I thought there was a meta on this but I can't find it.) – Neil Aug 30 '17 at 12:18
• @Neil The eval "trick" would be this loophole in spirit, even if not explicitly stated. This answer here is kinda clever, though. – AdmBorkBork Aug 30 '17 at 12:36
• Yeah, I was debating whether to post eval as a serious answer. A workaround for future challenges like this might be to include inputs as part of the byte count. – darrylyeo Aug 30 '17 at 22:17

Perl 5, 149 +1 (-p) = 150 bytes

$d=<>;chomp;$_=($q=$"x11 .'/'.'-'x(1+2*length)."/\n").'|-DI>-/---< '.s/./$& /gr."<\n".$q=~y|\\/|/\\|r;if($d){y|<>|><|;$_=reverse;s/>/ >/;s|-/-|-\\-|}


Try it online!

Two line input. First is the message. Second is 0 for left, 1 for right.

V, 73, 65 bytes

Ó./&
É ÄÒ-ys$/YGpr$.11>Hj|R|-DI>-/³-<A< ÀñkæG|æ}-r>BR>³-\-<  Try it online! Not the greatest score, but that's because almost half of this comes from reversing the output. Hexdump: 00000000: d32e 2f26 200a c920 c4d2 2d79 7324 2f59 ../& .. ..-ys/Y 00000010: 4770 725c 242e 3131 3e48 6a7c 527c 2d44 Gpr$.11>Hj|R|-D 00000020: 493e 2d2f b32d 3c1b 413c 201b c0f1 6be6 I>-/.-<.A< ...k. 00000030: 477c e616 7d2d 723e 2442 523e b32d 5c2d G|..}-r>$BR>.-\-
00000040: 3c                                       <


Takes the string as input to the buffer, and the direction as 0 for left and 1 for right as command line arguments.

05AB1E, 63 bytes

„\\S'-¹g·>×ýD∞2äθ‚11ú"|-DI>-/---<"¸¹ε²i∞θ}J'<«S«ð«J¸«Àε²i∞2äθ}»


Try it online!

Based off bugs that may get fixed in the future.

• @MagicOctopusUrn possibly – Erik the Outgolfer Aug 30 '17 at 8:37
• @MagicOctopusUrn actually no it won't work like that... – Erik the Outgolfer Aug 30 '17 at 8:46
• @MagicOctopusUrn Try to change the 0 on the second line to a 1. – Erik the Outgolfer Aug 31 '17 at 14:25
• Ah, the leading space... – Magic Octopus Urn Aug 31 '17 at 14:27

Charcoal, 444039 35 bytes

|-DI>-/³↗<→/-ＬηＬη↙¹←< ¿Ｎ↷⁴‖Ｔ⮌⪫η ‖Ｂ↓


Try it online! Link is to verbose version of code. First input is 1 for right and 0 for left, second is banner string. Edit: Saved 1 byte by using ReflectButterfly(:Up) as ReflectButterfly(:Down) currently has a cursor positioning bug, but I saved a further 4 bytes by reversing the print direction, and now it doesn't matter which I use. 38 34 32 byte version if mirroring the banner was allowed:

|-DI>-/³Ｐ⪫⪫<<η ↘→\-ＬηＬη↖¹‖Ｂ↑¿Ｎ‖Ｔ


Try it online! Link is to verbose version of code. First input is 0 for right and 1 for left. Explanation:

|-DI>-/


Print the plane.

³↗<→/-ＬηＬη↙¹←<


Print the top half of the box (note trailing space).

¿Ｎ↷⁴‖Ｔ


If the second input is nonzero, reverse the print direction, otherwise reflect the plane and box.

⮌⪫η


Print the message with extra spacing (note trailing space). The cursor is at the far end of the box from the plane so the message needs to be reversed.

‖Ｂ↓


Reflect to get the bottom half of the box.

• Verbose version seems to have issues. – Erik the Outgolfer Aug 30 '17 at 11:16
• @EriktheOutgolfer Deverbosifier was broken recently; TIO doesn't seem to have the fix yet. – Neil Aug 30 '17 at 12:10

Jelly, 68 65 bytes

“/\<“\/>”y
³K“|-DI>-/---< “ < ”j
LḤ‘”-x⁾//jṭ⁶x11¤Fµ,Ñj¢œs3U⁴¡YÑ⁴¡


Try it online!

Takes 1 for right, 0 for left.

-3 bytes thanks to @JonathanAllan (grr I always forget AB+ does the same as B+@A)

• ³K“|-DI>-/---< “ < ”j saves a byte; LḤ‘”-x⁾//jṭ⁶x11¤Fµ,Ñj¢œs3U⁴¡YÑ⁴¡ saves another 2 in the same fashion. – Jonathan Allan Aug 30 '17 at 1:25

Charcoal, 56 bytes

-8 bytes thanks to totallyhuman and Erik the Outgolfer!

≔⪫Ｓ θ≔⁺Ｌθ²η× ¹¹/η/⸿|-DI>-/³<× η<‖Ｂ↓ＦＮ«‖ＴＭ⁺η³→≔⮌θθ»↑↑Ｍη←θ


Try it online!

Fixing the cases dzaima mentioned took quite a toll on the byte count. 36 bytes if we are allowed to reverse characters like < and /.

• In python, ' '.join(s) works. Surely that can be used in Charcoal? – totallyhuman Aug 29 '17 at 15:29
• @totallyhuman Join works on strings too. – Erik the Outgolfer Aug 29 '17 at 15:46
• Umm, I think it was totallyhuman who actually suggested that. – Erik the Outgolfer Aug 29 '17 at 18:01
• @EriktheOutgolfer Oh, I misinterpreted @totallyhuman's suggestion as making a call to Python's ' '.join in Charcoal. I'll credit both of you. – notjagan Aug 29 '17 at 18:02
• You've broken the ast processor... – Neil Aug 29 '17 at 18:53

SOGL V0.12, 5547 43 bytes

└"┐ξA∫Ν┌r4≥‘┘¹§,{e⌡↔@¹"╝′‰‘┼}"-<-/ \”┼e?±↔


Try it Here!

0 for left and 1 for right

Python 2, 137136 133 bytes

lambda s,d:'{0}/{1}-/\n|-DI{3}-{4}---{5} {2} {5} \n{0}\\-{1}\\'.format(' '*11,'--'*len(s),' '.join(s),*list('></\\<>')[d::2])[::-d|1]


Try it online!

1 for right and 0 for left

• 135 bytes (-1 byte) by replacing 1-2*d with -d|1 (negate d xor 1). – Mr. Xcoder Aug 29 '17 at 16:02
• Typo, it's not xor, it's bitwise or, in fact. – Mr. Xcoder Aug 29 '17 at 16:09
• 134 bytes with a little trick: *list('></\\<>')[d::2] – jferard Aug 29 '17 at 19:55

PHP, 175 bytes

[,$d,$s]=$argv;$f=str_repeat("--",strlen($s));$r="\-$f\ ".join(" ",str_split("><"[$d].$s)).($d?" <---/->":" >---\-<")."ID-|
/-$f/ ";echo$d?strrev($r):$r;


Run with -nr, first argument = 0 for facing right or 1 for left and second argument=text
or try it online.

Perl 5, 126 bytes

124 bytes code + 2 for -pl.

s/./$& /g;$_=($q=$"x11 .'/-'.s/./-/gr."/
")."|-DI>-/---< $_< ".$q=~y|\\/|/\\|r;<>&&(y|<>|><|,$_=reverse,s/>/ >/,s|-/-|-\\-|)  Try it online! Corea, 51 bytes "u *:>ip.j:l)X-'/S:>" |-DI>-/---< V< "h}>>tHLidF  Try it online! Explanation The program is composed of a few parts: 1: Initialization "u *:>ip.j:l)X-'/S:>" "..................." execute the inside as code u repeat * a space, 11 times : duplicate this string > write this string to the content field i take a line of input p push a space .j insert that space after every character :l) get (length(str) + 1) X- repeat a hyphen that many times '/ push the "/" character S surround that string with the above character :> duplicate and write that string to the content field  2: raw text The following text is outputted to the content field: |-DI>-/---< V<  3: postamble "h}>>tHLidF " execute until the end of the file h mirror the previous string horizontally } move the modified input string to the front of the stack >> write the top two strings to the content field  id do the inside input times tH reflect the content field horizontally and vertically L reverse the input string F save the input string in a field (default: V) this replaces all Vs in the code with the input string  Excel VBA, 198 Bytes Anonymous VBE immediate window function that takes input as string from [A1] and int from range [B1] where 1 indicates that the plane is on the left and 0 indicates that the plane is on the right. b=[B1]:a=StrConv(IIf(b,[A1],StrReverse([A1])),64):j=[Rept("-",2*Len(A1)+1)]:k="/"&j &"/":l="\"&j &"\":s=Space(11):?IIf(b,s &k,l):?IIf(b,"|-DI>-/---< "," > ")a;IIf(b,"<",">---\-<ID-|"):?IIf(b,s &l,k)  Google Sheets, 210 Bytes Anonymous worksheet function that takes input input as string from [A1] and int from range [B1] where 1 indicates that the plane is on the left and 0 indicates that the plane is on the right. =If(B1," /","\")&Rept("-",2*Len(A1)+1)&If(B1,"/ ","\ ")&If(B1,"|-DI>-/---< "," > ")&RegexReplace(A1,"(.)","$1 ")&If(B1,"<
",">---\-<ID-|
")&If(B1,"           \","/")&Rept("-",2*Len(A1)+1)&If(B1,"\","/
`