Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: layout_rename_ph_labels() to rename ph labels in layouts (#610) #614

Merged
merged 4 commits into from
Sep 30, 2024

Conversation

markheckmann
Copy link
Contributor

Two new functions added: layout_rename_ph_labels() and layout_rename_ph_labels()<- to rename ph labels (#610).


Example

library(officer)

x <- read_pptx()
layout <- "Comparison"
plot_layout <- \() plot_layout_properties(x, layout) # helper fun

# initial labels
plot_layout()

# rename using key-value pairs: 'old label' = 'new label' or 'id' = 'new label'
layout_rename_ph_labels(x, layout, "Date Placeholder 6" = "DATE", "8" = "FOOTER") # label and id
plot_layout()

# rename using a named list and the .dots arg
renames <- list("Content Placeholder 3" = "CONTENT_1", "6" = "CONTENT_2")
layout_rename_ph_labels(x,layout, .dots = renames)
plot_layout()

# rename via rhs assignment and optional index (not id!)
layout_rename_ph_labels(x, layout) <- LETTERS[1:8]
plot_layout()

# rename via rhs assignment and ph id (not index)
layout_rename_ph_labels(x, layout, id = c(2, 4)) <- paste("ID =", c(2, 4))
plot_layout()

Created on 2024-09-30 with reprex v2.1.1

image

@markheckmann markheckmann changed the title Issue 610 rename ph label feat: layout_rename_ph_labels() to rename ph labels in layouts (#610) Sep 30, 2024
@davidgohel davidgohel merged commit 856d3b0 into davidgohel:master Sep 30, 2024
3 checks passed
@john-harrold
Copy link
Contributor

This is cool. Thank you for doing it Mark.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants