Skip to main content
10 events
when toggle format what by license comment
Jul 24, 2019 at 19:01 comment added Eoin It doesn't work though, I'll open another question
Jul 24, 2019 at 18:49 comment added Eoin Sorry I've looked at it in my code editor now and it makes sense. Cheers!
Jul 21, 2019 at 21:50 comment added mickmackusa If there is a new class, it will be set. The condition block is purely about how the new class will be set() -- as the sole class or a subsequent class.
Jul 21, 2019 at 21:46 comment added mickmackusa In my snippet, using .= (concatenating assignment) streamlines the codes by removing the need to write the variable name on both sides of the assignment. And in the else, only assignment is used for "tinfoil hat" reasons. (For instance, someone writes an invalid class like class="0" -- empty() evaluates 0 as true, and concatenating will create class="0 newClassName") Beyond this wacky fringe case, you could use concatenating assignment in both branches. If you do, you could entertain the idea of writing an inline (ternary) condition statement -- but that will make a long line.
Jul 20, 2019 at 13:55 comment added Eoin I'm not entirely sure why you use .= instead of just =. I get what it does, but I've usually seen it used when multiple variables are assigned in a row. But my main point is in the else statement I seem to be looking up params just to assign an empty class. But we already checked if it was empty earlier, so really no need. Could assign "" or just not assign anything. Is that right? Or have I still gotten confused
Jul 20, 2019 at 13:11 comment added mickmackusa In my snippet, if the gotten class is not empty, I am using .= to append space and the new class. If the gotten class is not set or falsey, I am not using concatenation -- I am setting the final class value as the new class. Your snippet is saying if the gotten class is not set or falsey, write the empty string followed by the new class value (no delimiting space required). Hmm, if I haven't explained this well enough, let me know and I'll try to say it differently.
Jul 20, 2019 at 12:35 comment added Eoin Thank you, this is much better than my simplistic way of coding. The one thing I am querying about my own code, and you have duplicated the error. I seem to be saying if $pageClass is not empty then prepend a space, but else (it is empty) then call it as it is. Surely if it's empty I don't need to do the else statement at all. But because I'm so noob I'm wondering if there was a reason for me doing that else in that way? Can you think of one?
Jul 20, 2019 at 3:52 comment added mickmackusa Code Review: 3v4l.org/BSZnB Perhaps I could entice you to refine your offering to use simpler conditional logic, efficient processes, and minimal variable declarations. This way no unnecessary work is done by the script. I'll leave you to decide if you want to adapt your answer or not. Just a suggestion.
Jan 5, 2019 at 15:36 history edited Eoin CC BY-SA 4.0
Corrected Errors
Jan 5, 2019 at 15:28 history answered Eoin CC BY-SA 4.0