Esolang-Comment-Template-Generator
Java 10, 189 159 bytes
s->c->{var r="";int p=0,i;for(var a:s.split("\\|")){for(i=p;i-->0;r+=" ");r+=a;for(p+=a.length();i++<s.replace("|","").length()-p;r+=" ");r+=c+"\n";}return r;}
-30 bytes converting Java 7 to Java 10 and optimizing the loops.
Try it online.
Explanation:
s->c->{ // Method with String & char parameters and String return-type
var r=""; // Result-String, starting empty
int p=0, // Position-integer, starting at 0
i; // Index integer
for(var a:s.split("\\|")){// Loop over the parts split by "|"
for(i=p;i-->0;r+=" "); // Add `p` amount of spaces to the result-String
r+=a; // Add the current part to the result-String
for(p+=a.length(); // Add the length of the current part to the position-integer
i++<s.replace("|","").length()-p;r+=" ");
// Add the row's trailing spaces to the result-String
r+=c+"\n";} // Add the character and a new-line to the result-String
return r;} // Return the result-String
Retina, 35 34 bytes
Byte count assumes ISO 8859-1 encoding.
\|
·$'¶$`±
T0-2`·±|p`___ `.+±.|·.+
The two input strings are separated by a space (which is unambiguous since we know that the comment delimiter is always a single character).
Try it online!
Pyke, 31 28 24 bytes
\|cDslF2l-hd*Q+Zi:il?+ZK
Try it here!